Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 7027fa2

Browse files
committed
Merging develop to master in preparation for 2.9.0 release.
2 parents e70ed2a + 71eab8e commit 7027fa2

File tree

12 files changed

+201
-21
lines changed

12 files changed

+201
-21
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
sudo: false
2-
31
language: php
42

53
cache:
@@ -54,6 +52,15 @@ matrix:
5452
- php: 7.2
5553
env:
5654
- DEPS=latest
55+
- php: 7.3
56+
env:
57+
- DEPS=lowest
58+
- php: 7.3
59+
env:
60+
- DEPS=locked
61+
- php: 7.3
62+
env:
63+
- DEPS=latest
5764

5865
before_install:
5966
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.9.0 - 2019-01-08
6+
7+
### Added
8+
9+
- [#154](https://github.com/zendframework/zend-http/pull/154) adds the method `SetCookie::setEncodeValue()`. By default, Set-Cookie
10+
values are passed through `urlencode()`; when a boolean `false` is provided to
11+
this new method, the raw value will be used instead.
12+
13+
- [#166](https://github.com/zendframework/zend-http/pull/166) adds support for PHP 7.3.
14+
15+
### Changed
16+
17+
- [#154](https://github.com/zendframework/zend-http/pull/154) changes the behavior of `SetCookie::fromString()` slightly: if the parsed
18+
cookie value is the same as the one passed through `urldecode()`, the
19+
`SetCookie` header's `$encodeValue` property will be toggled off to ensure the
20+
value is not encoded in subsequent serializations, thus retaining the
21+
integrity of the value between usages.
22+
23+
- [#161](https://github.com/zendframework/zend-http/pull/161) changes how the Socket and Test adapters aggregate headers. Previously,
24+
they would `ucfirst()` the header name; now, they correctly leave the header
25+
names untouched, as header names should be considered case-insensitive.
26+
27+
- [#156](https://github.com/zendframework/zend-http/pull/156) changes how gzip and deflate decompression occur in responses, ensuring
28+
that if the Content-Length header reports 0, no decompression is attempted,
29+
and an empty string is returned.
30+
31+
### Deprecated
32+
33+
- Nothing.
34+
35+
### Removed
36+
37+
- [#166](https://github.com/zendframework/zend-http/pull/166) removes support for zend-stdlib v2 releases.
38+
39+
### Fixed
40+
41+
- Nothing.
42+
543
## 2.8.3 - 2019-01-08
644

745
### Added

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"require": {
2121
"php": "^5.6 || ^7.0",
2222
"zendframework/zend-loader": "^2.5.1",
23-
"zendframework/zend-stdlib": "^3.1 || ^2.7.7",
23+
"zendframework/zend-stdlib": "^3.2.1",
2424
"zendframework/zend-uri": "^2.5.2",
2525
"zendframework/zend-validator": "^2.10.1"
2626
},
@@ -47,8 +47,8 @@
4747
},
4848
"extra": {
4949
"branch-alias": {
50-
"dev-master": "2.8.x-dev",
51-
"dev-develop": "2.9.x-dev"
50+
"dev-master": "2.9.x-dev",
51+
"dev-develop": "2.10.x-dev"
5252
}
5353
},
5454
"scripts": {

composer.lock

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Client/Adapter/Socket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = ''
389389
$request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n";
390390
foreach ($headers as $k => $v) {
391391
if (is_string($k)) {
392-
$v = ucfirst($k) . ': ' . $v;
392+
$v = $k . ': ' . $v;
393393
}
394394
$request .= $v . "\r\n";
395395
}

src/Client/Adapter/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = ''
132132
$request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n";
133133
foreach ($headers as $k => $v) {
134134
if (is_string($k)) {
135-
$v = ucfirst($k) . ': ' . $v;
135+
$v = $k . ': ' . $v;
136136
}
137137
$request .= $v . "\r\n";
138138
}

src/Header/Cookie.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ public function __construct(array $array = [])
7575
parent::__construct($array, ArrayObject::ARRAY_AS_PROPS);
7676
}
7777

78+
/**
79+
* @param bool $encodeValue
80+
*
81+
* @return $this
82+
*/
7883
public function setEncodeValue($encodeValue)
7984
{
8085
$this->encodeValue = (bool) $encodeValue;
8186
return $this;
8287
}
8388

89+
/**
90+
* @return bool
91+
*/
8492
public function getEncodeValue()
8593
{
8694
return $this->encodeValue;

src/Header/SetCookie.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ class SetCookie implements MultipleHeaderInterface
8585
*/
8686
protected $httponly;
8787

88+
/**
89+
* @var bool
90+
*/
91+
protected $encodeValue = true;
92+
8893
/**
8994
* @static
9095
* @throws Exception\InvalidArgumentException
@@ -99,6 +104,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
99104
if ($setCookieProcessor === null) {
100105
$setCookieClass = get_called_class();
101106
$setCookieProcessor = function ($headerLine) use ($setCookieClass) {
107+
/** @var SetCookie $header */
102108
$header = new $setCookieClass();
103109
$keyValuePairs = preg_split('#;\s*#', $headerLine);
104110

@@ -115,6 +121,11 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
115121
if ($header->getName() === null) {
116122
$header->setName($headerKey);
117123
$header->setValue(urldecode($headerValue));
124+
125+
// set no encode value if raw and encoded values are the same
126+
if (urldecode($headerValue) === $headerValue) {
127+
$header->setEncodeValue(false);
128+
}
118129
continue;
119130
}
120131

@@ -213,6 +224,22 @@ public function __construct(
213224
->setHttpOnly($httponly);
214225
}
215226

227+
/**
228+
* @return bool
229+
*/
230+
public function getEncodeValue()
231+
{
232+
return $this->encodeValue;
233+
}
234+
235+
/**
236+
* @param bool $encodeValue
237+
*/
238+
public function setEncodeValue($encodeValue)
239+
{
240+
$this->encodeValue = (bool) $encodeValue;
241+
}
242+
216243
/**
217244
* @return string 'Set-Cookie'
218245
*/
@@ -231,7 +258,7 @@ public function getFieldValue()
231258
return '';
232259
}
233260

234-
$value = urlencode($this->getValue());
261+
$value = $this->encodeValue ? urlencode($this->getValue()) : $this->getValue();
235262
if ($this->hasQuoteFieldValue()) {
236263
$value = '"' . $value . '"';
237264
}

src/Response.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ protected function decodeGzip($body)
564564
);
565565
}
566566

567+
if ($this->getHeaders()->has('content-length')
568+
&& 0 === (int) $this->getHeaders()->get('content-length')->getFieldValue()) {
569+
return '';
570+
}
571+
567572
ErrorHandler::start();
568573
$return = gzinflate(substr($body, 10));
569574
$test = ErrorHandler::stop();
@@ -594,6 +599,11 @@ protected function decodeDeflate($body)
594599
);
595600
}
596601

602+
if ($this->getHeaders()->has('content-length')
603+
&& 0 === (int) $this->getHeaders()->get('content-length')->getFieldValue()) {
604+
return '';
605+
}
606+
597607
/**
598608
* Some servers (IIS ?) send a broken deflate response, without the
599609
* RFC-required zlib header.

test/Client/SocketTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,24 @@ public function testAllowsZeroWrittenBytes()
339339
$this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', [], 'test body');
340340
}
341341

342+
/**
343+
* Verifies that the headers are being set as given without changing any
344+
* character case.
345+
*/
346+
public function testCaseInsensitiveHeaders()
347+
{
348+
$this->_adapter->connect('localhost');
349+
$requestString = $this->_adapter->write(
350+
'GET',
351+
new Uri('tcp://localhost:80/'),
352+
'1.1',
353+
['x-test-header' => 'someTestHeader'],
354+
'someTestBody'
355+
);
356+
357+
$this->assertContains('x-test-header', $requestString);
358+
}
359+
342360
/**
343361
* Data Providers
344362
*/

0 commit comments

Comments
 (0)