Skip to content

Commit 598d02d

Browse files
committed
Merge pull request #110 from mishan/fix-issue-109
Address Issue #109
2 parents 8ee5f30 + bae4b75 commit 598d02d

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/Google/IO/Abstract.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ abstract public function setTimeout($timeout);
6868
*/
6969
abstract public function getTimeout();
7070

71+
/**
72+
* Determine whether "Connection Established" quirk is needed
73+
* @return boolean
74+
*/
75+
abstract protected function _needsQuirk();
76+
7177
/**
7278
* @visible for testing.
7379
* Cache the response to an HTTP request if it is cacheable.
@@ -238,7 +244,8 @@ protected function updateCachedRequest($cached, $responseHeaders)
238244
*/
239245
public function parseHttpResponse($respData, $headerSize)
240246
{
241-
if (stripos($respData, self::CONNECTION_ESTABLISHED) !== false) {
247+
// only strip this header if the sub-class needs this quirk
248+
if ($this->_needsQuirk() && stripos($respData, self::CONNECTION_ESTABLISHED) !== false) {
242249
$respData = str_ireplace(self::CONNECTION_ESTABLISHED, '', $respData);
243250
}
244251

src/Google/IO/Curl.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
class Google_IO_Curl extends Google_IO_Abstract
2727
{
28+
// hex for version 7.31.0
29+
const NO_QUIRK_VERSION = 0x071F00;
30+
2831
private $options = array();
2932
/**
3033
* Execute an HTTP Request
@@ -118,4 +121,15 @@ public function getTimeout()
118121
{
119122
return $this->options[CURLOPT_TIMEOUT];
120123
}
124+
125+
/**
126+
* Determine whether "Connection Established" quirk is needed
127+
* @return boolean
128+
*/
129+
protected function _needsQuirk()
130+
{
131+
$ver = curl_version();
132+
$versionNum = $ver['version_number'];
133+
return $versionNum < static::NO_QUIRK_VERSION;
134+
}
121135
}

src/Google/IO/Stream.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ public function getTimeout()
156156
return $this->options[self::TIMEOUT];
157157
}
158158

159+
/**
160+
* Determine whether "Connection Established" quirk is needed
161+
* @return boolean
162+
*/
163+
protected function _needsQuirk()
164+
{
165+
// Stream needs the special quirk
166+
return true;
167+
}
168+
159169
protected function getHttpResponseCode($response_headers)
160170
{
161171
$header_count = count($response_headers);

0 commit comments

Comments
 (0)