Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/curl_response.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CurlResponse {
**/
function __construct($response) {
# Headers regex
$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
$pattern = '#HTTP/\d(\.\d)? .*?$.*?\r\n\r\n#ims';

# Extract headers from response
preg_match_all($pattern, $response, $matches);
Expand All @@ -53,10 +53,10 @@ function __construct($response) {

# Extract the version and status from the first header
$version_and_status = array_shift($headers);
preg_match_all('#HTTP/(\d\.\d)\s((\d\d\d)\s((.*?)(?=HTTP)|.*))#', $version_and_status, $matches);
preg_match_all('#HTTP/(\d(\.\d)?)\s((\d\d\d)\s((.*?)(?=HTTP)|.*))#', $version_and_status, $matches);
$this->headers['Http-Version'] = array_pop($matches[1]);
$this->headers['Status-Code'] = array_pop($matches[3]);
$this->headers['Status'] = array_pop($matches[2]);
$this->headers['Status-Code'] = sizeof($matches) == 6 ? array_pop($matches[3]) : array_pop($matches[4]);
$this->headers['Status'] = sizeof($matches) == 6 ? array_pop($matches[2]) : array_pop($matches[3]);

# Convert headers into an associative array
foreach ($headers as $header) {
Expand Down