Add support for CURLINFO_HEADER_OUT #261
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
When
curl_setopt($ch, CURLINFO_HEADER_OUT, true)
has been called before a request is sent you should then be able to callcurl_getinfo($ch, CURLINFO_HEADER_OUT)
after the request to get a description of the request that's been sent. Prior to this patch callingcurl_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.