Skip to content

Commit 1bf06c8

Browse files
committed
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')
1 parent b38a0e9 commit 1bf06c8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 HTTP client extension Change Log
44
2.0.13 under development
55
------------------------
66

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

99

1010
2.0.12 October 08, 2019

src/Message.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public function getHeaders()
8585
if (strpos($rawHeader, 'HTTP/') === 0) {
8686
$parts = explode(' ', $rawHeader, 3);
8787
$headerCollection->add('http-code', $parts[1]);
88+
$headerCollection->add('http-status-line',$rawHeader);
89+
$headerCollection->add('http-version',$parts[0]);
90+
$headerCollection->add('http-status-code-reason-phrase',trim($parts[1].' '.sizeof($parts)>2?trim($parts[2]):''));
8891
} elseif (($separatorPos = strpos($rawHeader, ':')) !== false) {
8992
$name = strtolower(trim(substr($rawHeader, 0, $separatorPos)));
9093
$value = trim(substr($rawHeader, $separatorPos + 1));
@@ -352,4 +355,4 @@ public function __toString()
352355
return '';
353356
}
354357
}
355-
}
358+
}

0 commit comments

Comments
 (0)