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

Commit d3bdfd0

Browse files
committed
Merge branch 'hotfix/3362' into develop
Forward port zendframework/zendframework#3362 Conflicts: library/Zend/Http/Client/Cookies.php library/Zend/Http/Cookies.php library/Zend/Soap/Client/Common.php library/Zend/Soap/Wsdl.php

File tree

6 files changed

+134
-133
lines changed

6 files changed

+134
-133
lines changed

src/Client/Adapter/AdapterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function connect($host, $port = 80, $secure = false);
4343
*
4444
* @param string $method
4545
* @param \Zend\Uri\Uri $url
46-
* @param string $http_ver
46+
* @param string $httpVer
4747
* @param array $headers
4848
* @param string $body
4949
* @return string Request as text
5050
*/
51-
public function write($method, $url, $http_ver = '1.1', $headers = array(), $body = '');
51+
public function write($method, $url, $httpVer = '1.1', $headers = array(), $body = '');
5252

5353
/**
5454
* Read response from server

src/Client/Adapter/Proxy.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ public function connect($host, $port = 80, $secure = false)
113113
*
114114
* @param string $method
115115
* @param \Zend\Uri\Uri $uri
116-
* @param string $http_ver
116+
* @param string $httpVer
117117
* @param array $headers
118118
* @param string $body
119119
* @throws AdapterException\RuntimeException
120120
* @return string Request as string
121121
*/
122-
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
122+
public function write($method, $uri, $httpVer = '1.1', $headers = array(), $body = '')
123123
{
124124
// If no proxy is set, fall back to default Socket adapter
125-
if (! $this->config['proxy_host']) return parent::write($method, $uri, $http_ver, $headers, $body);
125+
if (! $this->config['proxy_host']) return parent::write($method, $uri, $httpVer, $headers, $body);
126126

127127
// Make sure we're properly connected
128128
if (! $this->socket) {
@@ -132,7 +132,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
132132
$host = $this->config['proxy_host'];
133133
$port = $this->config['proxy_port'];
134134

135-
if ($this->connected_to[0] != "tcp://$host" || $this->connected_to[1] != $port) {
135+
if ($this->connectedTo[0] != "tcp://$host" || $this->connectedTo[1] != $port) {
136136
throw new AdapterException\RuntimeException("Trying to write but we are connected to the wrong proxy server");
137137
}
138138

@@ -145,7 +145,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
145145

146146
// if we are proxying HTTPS, preform CONNECT handshake with the proxy
147147
if ($uri->getScheme() == 'https' && (! $this->negotiated)) {
148-
$this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
148+
$this->connectHandshake($uri->getHost(), $uri->getPort(), $httpVer, $headers);
149149
$this->negotiated = true;
150150
}
151151

@@ -158,9 +158,9 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
158158
if ($uri->getQuery()) {
159159
$path .= '?' . $uri->getQuery();
160160
}
161-
$request = "$method $path HTTP/$http_ver\r\n";
161+
$request = "$method $path HTTP/$httpVer\r\n";
162162
} else {
163-
$request = "$method $uri HTTP/$http_ver\r\n";
163+
$request = "$method $uri HTTP/$httpVer\r\n";
164164
}
165165

166166
// Add all headers to the request string
@@ -198,13 +198,13 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
198198
*
199199
* @param string $host
200200
* @param integer $port
201-
* @param string $http_ver
201+
* @param string $httpVer
202202
* @param array $headers
203203
* @throws AdapterException\RuntimeException
204204
*/
205-
protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
205+
protected function connectHandshake($host, $port = 443, $httpVer = '1.1', array &$headers = array())
206206
{
207-
$request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
207+
$request = "CONNECT $host:$port HTTP/$httpVer\r\n" .
208208
"Host: " . $this->config['proxy_host'] . "\r\n";
209209

210210
// Add the user-agent header

src/Client/Adapter/Socket.php

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class Socket implements HttpAdapter, StreamInterface
5151
*
5252
* @var array
5353
*/
54-
protected $connected_to = array(null, null);
54+
protected $connectedTo = array(null, null);
5555

5656
/**
5757
* Stream for storing output
5858
*
5959
* @var resource
6060
*/
61-
protected $out_stream = null;
61+
protected $outStream = null;
6262

6363
/**
6464
* Parameters array
@@ -189,11 +189,11 @@ public function getStreamContext()
189189
public function connect($host, $port = 80, $secure = false)
190190
{
191191
// If we are connected to the wrong host, disconnect first
192-
$connected_host = (strpos($this->connected_to[0], '://'))
193-
? substr($this->connected_to[0], (strpos($this->connected_to[0], '://') + 3), strlen($this->connected_to[0]))
194-
: $this->connected_to[0];
192+
$connectedHost = (strpos($this->connectedTo[0], '://'))
193+
? substr($this->connectedTo[0], (strpos($this->connectedTo[0], '://') + 3), strlen($this->connectedTo[0]))
194+
: $this->connectedTo[0];
195195

196-
if ($connected_host != $host || $this->connected_to[1] != $port) {
196+
if ($connectedHost != $host || $this->connectedTo[1] != $port) {
197197
if (is_resource($this->socket)) {
198198
$this->close();
199199
}
@@ -313,8 +313,8 @@ public function connect($host, $port = 80, $secure = false)
313313
$host = 'tcp://' . $host;
314314
}
315315

316-
// Update connected_to
317-
$this->connected_to = array($host, $port);
316+
// Update connectedTo
317+
$this->connectedTo = array($host, $port);
318318
}
319319
}
320320

@@ -324,13 +324,13 @@ public function connect($host, $port = 80, $secure = false)
324324
*
325325
* @param string $method
326326
* @param \Zend\Uri\Uri $uri
327-
* @param string $http_ver
327+
* @param string $httpVer
328328
* @param array $headers
329329
* @param string $body
330330
* @throws AdapterException\RuntimeException
331331
* @return string Request as string
332332
*/
333-
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
333+
public function write($method, $uri, $httpVer = '1.1', $headers = array(), $body = '')
334334
{
335335
// Make sure we're properly connected
336336
if (! $this->socket) {
@@ -339,7 +339,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
339339

340340
$host = $uri->getHost();
341341
$host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
342-
if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
342+
if ($this->connectedTo[0] != $host || $this->connectedTo[1] != $uri->getPort()) {
343343
throw new AdapterException\RuntimeException('Trying to write but we are connected to the wrong host');
344344
}
345345

@@ -349,7 +349,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
349349
// Build request headers
350350
$path = $uri->getPath();
351351
if ($uri->getQuery()) $path .= '?' . $uri->getQuery();
352-
$request = "{$method} {$path} HTTP/{$http_ver}\r\n";
352+
$request = "{$method} {$path} HTTP/{$httpVer}\r\n";
353353
foreach ($headers as $k => $v) {
354354
if (is_string($k)) $v = ucfirst($k) . ": $v";
355355
$request .= "$v\r\n";
@@ -427,11 +427,11 @@ public function read()
427427
}
428428

429429
// If we got a 'transfer-encoding: chunked' header
430-
$transfer_encoding = $headers->get('transfer-encoding');
431-
$content_length = $headers->get('content-length');
432-
if ($transfer_encoding !== false) {
430+
$transferEncoding = $headers->get('transfer-encoding');
431+
$contentLength = $headers->get('content-length');
432+
if ($transferEncoding !== false) {
433433

434-
if (strtolower($transfer_encoding->getFieldValue()) == 'chunked') {
434+
if (strtolower($transferEncoding->getFieldValue()) == 'chunked') {
435435

436436
do {
437437
$line = fgets($this->socket);
@@ -451,19 +451,19 @@ public function read()
451451
$chunksize = hexdec($chunksize);
452452

453453
// Read next chunk
454-
$read_to = ftell($this->socket) + $chunksize;
454+
$readTo = ftell($this->socket) + $chunksize;
455455

456456
do {
457-
$current_pos = ftell($this->socket);
458-
if ($current_pos >= $read_to) break;
457+
$currentPos = ftell($this->socket);
458+
if ($currentPos >= $readTo) break;
459459

460-
if ($this->out_stream) {
461-
if (stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
460+
if ($this->outStream) {
461+
if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) == 0) {
462462
$this->_checkSocketReadTimeout();
463463
break;
464464
}
465465
} else {
466-
$line = fread($this->socket, $read_to - $current_pos);
466+
$line = fread($this->socket, $readTo - $currentPos);
467467
if ($line === false || strlen($line) === 0) {
468468
$this->_checkSocketReadTimeout();
469469
break;
@@ -477,45 +477,45 @@ public function read()
477477
ErrorHandler::stop();
478478
$this->_checkSocketReadTimeout();
479479

480-
if (!$this->out_stream) {
480+
if (!$this->outStream) {
481481
$response .= $chunk;
482482
}
483483
} while ($chunksize > 0);
484484
} else {
485485
$this->close();
486486
throw new AdapterException\RuntimeException('Cannot handle "' .
487-
$transfer_encoding->getFieldValue() . '" transfer encoding');
487+
$transferEncoding->getFieldValue() . '" transfer encoding');
488488
}
489489

490490
// We automatically decode chunked-messages when writing to a stream
491491
// this means we have to disallow the Zend_Http_Response to do it again
492-
if ($this->out_stream) {
492+
if ($this->outStream) {
493493
$response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $response);
494494
}
495495
// Else, if we got the content-length header, read this number of bytes
496-
} elseif ($content_length !== false) {
496+
} elseif ($contentLength !== false) {
497497

498498
// If we got more than one Content-Length header (see ZF-9404) use
499499
// the last value sent
500-
if (is_array($content_length)) {
501-
$content_length = $content_length[count($content_length) - 1];
500+
if (is_array($contentLength)) {
501+
$contentLength = $contentLength[count($contentLength) - 1];
502502
}
503-
$contentLength = $content_length->getFieldValue();
503+
$contentLength = $contentLength->getFieldValue();
504504

505-
$current_pos = ftell($this->socket);
505+
$currentPos = ftell($this->socket);
506506
$chunk = '';
507507

508-
for ($read_to = $current_pos + $contentLength;
509-
$read_to > $current_pos;
510-
$current_pos = ftell($this->socket)) {
508+
for ($readTo = $currentPos + $contentLength;
509+
$readTo > $currentPos;
510+
$currentPos = ftell($this->socket)) {
511511

512-
if ($this->out_stream) {
513-
if (stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
512+
if ($this->outStream) {
513+
if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) == 0) {
514514
$this->_checkSocketReadTimeout();
515515
break;
516516
}
517517
} else {
518-
$chunk = fread($this->socket, $read_to - $current_pos);
518+
$chunk = fread($this->socket, $readTo - $currentPos);
519519
if ($chunk === false || strlen($chunk) === 0) {
520520
$this->_checkSocketReadTimeout();
521521
break;
@@ -532,8 +532,8 @@ public function read()
532532
} else {
533533

534534
do {
535-
if ($this->out_stream) {
536-
if (stream_copy_to_stream($this->socket, $this->out_stream) == 0) {
535+
if ($this->outStream) {
536+
if (stream_copy_to_stream($this->socket, $this->outStream) == 0) {
537537
$this->_checkSocketReadTimeout();
538538
break;
539539
}
@@ -573,7 +573,7 @@ public function close()
573573
ErrorHandler::stop();
574574
}
575575
$this->socket = null;
576-
$this->connected_to = array(null, null);
576+
$this->connectedTo = array(null, null);
577577
}
578578

579579
/**
@@ -605,7 +605,7 @@ protected function _checkSocketReadTimeout()
605605
*/
606606
public function setOutputStream($stream)
607607
{
608-
$this->out_stream = $stream;
608+
$this->outStream = $stream;
609609
return $this;
610610
}
611611

src/Client/Adapter/Test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ public function connect($host, $port = 80, $secure = false)
122122
*
123123
* @param string $method
124124
* @param \Zend\Uri\Uri $uri
125-
* @param string $http_ver
125+
* @param string $httpVer
126126
* @param array $headers
127127
* @param string $body
128128
* @return string Request as string
129129
*/
130-
public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
130+
public function write($method, $uri, $httpVer = '1.1', $headers = array(), $body = '')
131131
{
132132
$host = $uri->getHost();
133133
$host = (strtolower($uri->getScheme()) == 'https' ? 'sslv2://' . $host : $host);
@@ -138,7 +138,7 @@ public function write($method, $uri, $http_ver = '1.1', $headers = array(), $bod
138138
$path = '/';
139139
}
140140
if ($uri->getQuery()) $path .= '?' . $uri->getQuery();
141-
$request = "{$method} {$path} HTTP/{$http_ver}\r\n";
141+
$request = "{$method} {$path} HTTP/{$httpVer}\r\n";
142142
foreach ($headers as $k => $v) {
143143
if (is_string($k)) $v = ucfirst($k) . ": $v";
144144
$request .= "$v\r\n";

0 commit comments

Comments
 (0)