Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Commit

Permalink
Fix 'Invalid response line.' in HTTP/2 (#20)
Browse files Browse the repository at this point in the history
When HTTP/2 is enabled, Twitter API will send **`HTTP/2 200 `**, which is priviously regarded as invalid.
  • Loading branch information
kb10uy authored and mpyw committed May 6, 2019
1 parent 447346f commit 9e634f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct($buffer, $ch)
$body_buffer = substr($buffer, $header_size);
$header_buffer = current(array_slice(explode("\r\n\r\n", $header_buffer), -1));
$lines = explode("\r\n", $header_buffer);
if (!preg_match('@\AHTTP/([\d.]+)\s+(\d{3})\s+(.+)\z@i', array_shift($lines), $matches)) {
if (!preg_match('@\AHTTP/([\d.]+)\s+(\d{3})\s+(.*)\z@i', array_shift($lines), $matches)) {
throw new \UnexpectedValueException('Invalid response line.');
}
$this->version = $matches[1];
Expand Down

0 comments on commit 9e634f6

Please sign in to comment.