diff --git a/src/parser/http/PhutilHTTPResponseParser.php b/src/parser/http/PhutilHTTPResponseParser.php --- a/src/parser/http/PhutilHTTPResponseParser.php +++ b/src/parser/http/PhutilHTTPResponseParser.php @@ -48,7 +48,7 @@ $matches = null; $ok = preg_match( - '(^HTTP/\S+\s+(\d+)\s+(.*)$)i', + '(^HTTP/\S+\s+(\d+)(?:\s+(.*))?$)i', $first_line, $matches); diff --git a/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php b/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php --- a/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php +++ b/src/parser/http/__tests__/PhutilHTTPResponseParserTestCase.php @@ -69,6 +69,27 @@ $input, id(new PhutilHTTPResponseParser()) ->setFollowLocationHeaders(true)); + + $input = <<assertParse( + array( + array( + 'code' => 200, + 'headers' => array( + array('Reason', 'none'), + ), + 'body' => + 'This response has no "reason-phrase", which is unusual but valid.', + ), + ), + $input, + id(new PhutilHTTPResponseParser())); } private function assertParse(array $expect, $input, $parser = null) {