[Curl] Add \r\n to HTTP status and headers to mimic what curl does#294
Open
clemherreman wants to merge 1 commit intophp-vcr:masterfrom
Open
[Curl] Add \r\n to HTTP status and headers to mimic what curl does#294clemherreman wants to merge 1 commit intophp-vcr:masterfrom
clemherreman wants to merge 1 commit intophp-vcr:masterfrom
Conversation
clemherreman
added a commit
to clemherreman/php-vcr
that referenced
this pull request
Jan 24, 2020
Merge remote-tracking branch 'origin/fix-http-header-line-feed-missing'
642c21f to
6dd0af7
Compare
clemherreman
added a commit
to clemherreman/php-vcr
that referenced
this pull request
Jan 24, 2020
[Curl] Add \r\n to HTTP status and headers to mimic what curl does
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
[ "Content-Type: text/html; charset=UTF-8", "Content-Encoding: gzip", ]However, cURL returns them more "raw", with the trailing
\r\nmandatory at the end of every HTTP header line:[ "Content-Type: text/html; charset=UTF-8\r\n", "Content-Encoding: gzip\r\n", ]This PR changes the PHP-VCR behavior. This is necessary to HTTP clients, like Symfony HTTP Client that rely on those
\r\nto 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\nto 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.