Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds 3 new header keys to $headerCollection.
1. 'http-status-line': The full status line (ie. 'HTTP/1.1 200 OK')
2. 'http-version': The http version returned from the server (ie. 'HTTP/1.1')
3.'http-status-code-reason-phrase': The status line without the HTTP version (ie. '200 OK')
  • Loading branch information
zmoddynamics committed May 17, 2020
1 parent b38a0e9 commit 1bf06c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 HTTP client extension Change Log
2.0.13 under development
------------------------

- no changes in this release.
- Enh #204: added additional keys to `Message::getHeaders()` to make full http status line details available to `Client::getHeaders()` (ClintZeringue)


2.0.12 October 08, 2019
Expand Down
5 changes: 4 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public function getHeaders()
if (strpos($rawHeader, 'HTTP/') === 0) {
$parts = explode(' ', $rawHeader, 3);
$headerCollection->add('http-code', $parts[1]);
$headerCollection->add('http-status-line',$rawHeader);
$headerCollection->add('http-version',$parts[0]);
$headerCollection->add('http-status-code-reason-phrase',trim($parts[1].' '.sizeof($parts)>2?trim($parts[2]):''));
} elseif (($separatorPos = strpos($rawHeader, ':')) !== false) {
$name = strtolower(trim(substr($rawHeader, 0, $separatorPos)));
$value = trim(substr($rawHeader, $separatorPos + 1));
Expand Down Expand Up @@ -352,4 +355,4 @@ public function __toString()
return '';
}
}
}
}

0 comments on commit 1bf06c8

Please sign in to comment.