Skip to content

Commit 360faae

Browse files
dakotakirill-konshin
authored andcommitted
Allow slightly malformed HTTP responses (#6)
This brings in guzzle#100 which allows for HTTP reponses that do not contain the trailing space (Which, while required by the RFC is not enforced by browsers, etc.)
1 parent dcd84bb commit 360faae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,10 @@ function parse_server_request($message, array $serverParams = array())
497497
function parse_response($message)
498498
{
499499
$data = _parse_message($message);
500-
if (!preg_match('/^HTTP\/.* [0-9]{3} .*/', $data['start-line'])) {
500+
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
501+
// between status-code and reason-phrase is required. But browsers accept
502+
// responses without space and reason as well.
503+
if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
501504
throw new \InvalidArgumentException('Invalid response string');
502505
}
503506
$parts = explode(' ', $data['start-line'], 3);

0 commit comments

Comments
 (0)