[Curl] Add \r\n to HTTP status and headers to mimic what curl does #294
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 returning the array of cURL raw headers, PHP-VCR returns them like this
However, cURL returns them more "raw", with the trailing
\r\n
mandatory at the end of every HTTP header line:This PR changes the PHP-VCR behavior. This is necessary to HTTP clients, like Symfony HTTP Client that rely on those
\r\n
to detect the end of the headers and the beginning of the request body, when parsing it. (or just to extract it viasubstr()
)What has been done
VCR/Util/HttpUtil:formatHeadersForCurl()
andVCR/Util/HttpUtil:formatAsStatusString()
now returns a trailing\r\n
to the HTTP status and HTTP header strings.This is the actual PHP cURL behavior.
Note: This could, however be a BC change if someone was relying on not having those
\r\n
. However, it would then break in actual cURL requests, so I doubt that it is the case.How to test
Unit tests were updated.