bug #35324 [HttpClient] Fix strict parsing of response status codes (Armando-Walmeric)

This PR was submitted for the master branch but it was squashed and merged into the 4.3 branch instead.

Discussion
----------

[HttpClient] Fix strict parsing of response status codes

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | No ticket opened
| License       | MIT
| Doc PR        | No new feature

If you wait a strict Http code response by the server were you request, but the server response isn't strict and only return HTTP/1.1 200 we have a problem without sense to be strict on regular expression.

Commits
-------

4aa953600f [HttpClient] Fix strict parsing of response status codes
This commit is contained in:
Nicolas Grekas 2020-01-13 18:23:15 +01:00
commit ec0333c081

View File

@ -223,7 +223,7 @@ trait ResponseTrait
private static function addResponseHeaders(array $responseHeaders, array &$info, array &$headers, string &$debug = ''): void
{
foreach ($responseHeaders as $h) {
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d) .*#', $h, $m)) {
if (11 <= \strlen($h) && '/' === $h[4] && preg_match('#^HTTP/\d+(?:\.\d+)? ([12345]\d\d)(?: |$)#', $h, $m)) {
if ($headers) {
$debug .= "< \r\n";
$headers = [];