From 1bf06c84b7a4d8851b0be290b7fbf414a7cb454e Mon Sep 17 00:00:00 2001 From: Clint Zeringue Date: Sat, 16 May 2020 21:13:24 -0500 Subject: [PATCH 1/2] Enh #204 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') --- CHANGELOG.md | 2 +- src/Message.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d661ee..b6316da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Message.php b/src/Message.php index 089db61..6a9ca3b 100644 --- a/src/Message.php +++ b/src/Message.php @@ -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)); @@ -352,4 +355,4 @@ public function __toString() return ''; } } -} \ No newline at end of file +} From e47babe2aebae952fdf213eef163b4fb8b58cf5c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 17 May 2020 19:51:44 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6316da..4991e9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 HTTP client extension Change Log 2.0.13 under development ------------------------ -- Enh #204: added additional keys to `Message::getHeaders()` to make full http status line details available to `Client::getHeaders()` (ClintZeringue) +- 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