Skip to content

Commit

Permalink
Allow slightly malformed HTTP responses (#6)
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
dakota authored and kirill-konshin committed May 29, 2018
1 parent dcd84bb commit 360faae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ function parse_server_request($message, array $serverParams = array())
function parse_response($message)
{
$data = _parse_message($message);
if (!preg_match('/^HTTP\/.* [0-9]{3} .*/', $data['start-line'])) {
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
// between status-code and reason-phrase is required. But browsers accept
// responses without space and reason as well.
if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
throw new \InvalidArgumentException('Invalid response string');
}
$parts = explode(' ', $data['start-line'], 3);
Expand Down

0 comments on commit 360faae

Please sign in to comment.