Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for CURLINFO_HEADER_OUT#261

Open
alnorth wants to merge 2 commits intophp-vcr:masterfrom
alnorth:fix-CURLINFO_HEADER_OUT
Open

Add support for CURLINFO_HEADER_OUT#261
alnorth wants to merge 2 commits intophp-vcr:masterfrom
alnorth:fix-CURLINFO_HEADER_OUT

Conversation

@alnorth
Copy link
Contributor

@alnorth alnorth commented Nov 19, 2018

Context

When curl_setopt($ch, CURLINFO_HEADER_OUT, true) has been called before a request is sent you should then be able to call curl_getinfo($ch, CURLINFO_HEADER_OUT) after the request to get a description of the request that's been sent. Prior to this patch calling curl_getinfo($ch, CURLINFO_HEADER_OUT) with VCR enabled would actually cause an exception. To compound the issue the error message was also quite confusing (see #201 for an example).

What has been done

I've taken a second run at solving this as it was still causing problems for me with the PayPal SDK. My previous attempt was #198. I have similar misgivings about this version as it does break down some separation of concerns, but I think that's inevitable with this. The response object really does have to know about the request object.

This also required a function to format the Request as a string. I've mimicked curl's output for a simple GET request, but doing it for a POST with a body would take much more work. It's got enough there fulfil my purposes at the moment. It feels like the sort of thing that there may be a standard PHP function out there to do, but I haven't found one.

How to test

Unit tests have been added.

@alnorth alnorth changed the title Fix curlinfo header out Add support for CURLINFO_HEADER_OUT Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant