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

Commit ebbc1e2

Browse files
author
Stephen Seliuk
committed
Added method "testProperlyHandlesProxyHeadersWithCurlBug2"
1 parent 819a78c commit ebbc1e2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/HttpClients/AbstractTestHttpClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ abstract class AbstractTestHttpClient extends PHPUnit_Framework_TestCase
77
Content-Type: text/html; charset=utf-8
88
Location: https://foobar.com/\r\n\r\n";
99
protected $fakeRawProxyHeader = "HTTP/1.0 200 Connection established\r\n\r\n";
10+
protected $fakeRawProxyHeader2 = "HTTP/1.0 200 Connection established
11+
Proxy-agent: Kerio Control/7.1.1 build 1971\r\n\r\n";
1012
protected $fakeRawHeader = "HTTP/1.1 200 OK
1113
Etag: \"9d86b21aa74d74e574bbb35ba13524a52deb96e3\"
1214
Content-Type: text/javascript; charset=UTF-8

tests/HttpClients/FacebookCurlHttpClientTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function testProperlyHandlesProxyHeaders()
270270
$this->assertEquals($headers, $this->fakeHeadersAsArray);
271271
}
272272

273-
public function testProperlyHandlesProxyHeadersWithCurlBug()
273+
public function testProperlyHandlesProxyHeadAdersWithCurlBug()
274274
{
275275
$rawHeader = $this->fakeRawProxyHeader . $this->fakeRawHeader;
276276
$this->curlMock
@@ -298,6 +298,34 @@ public function testProperlyHandlesProxyHeadersWithCurlBug()
298298
$this->assertEquals($headers, $this->fakeHeadersAsArray);
299299
}
300300

301+
public function testProperlyHandlesProxyHeadersWithCurlBug2()
302+
{
303+
$rawHeader = $this->fakeRawProxyHeader2 . $this->fakeRawHeader;
304+
$this->curlMock
305+
->shouldReceive('getinfo')
306+
->with(CURLINFO_HEADER_SIZE)
307+
->once()
308+
->andReturn(mb_strlen($this->fakeRawHeader)); // Mimic bug that doesn't count proxy header
309+
$this->curlMock
310+
->shouldReceive('version')
311+
->once()
312+
->andReturn(array('version_number' => self::CURL_VERSION_BUGGY));
313+
$this->curlMock
314+
->shouldReceive('exec')
315+
->once()
316+
->andReturn($rawHeader . $this->fakeRawBody);
317+
318+
$this->curlClient->sendRequest();
319+
list($rawHeaders, $rawBody) = $this->curlClient->extractResponseHeadersAndBody();
320+
321+
$this->assertEquals($rawHeaders, trim($rawHeader));
322+
$this->assertEquals($rawBody, $this->fakeRawBody);
323+
324+
$headers = FacebookCurlHttpClient::headersToArray($rawHeaders);
325+
326+
$this->assertEquals($headers, $this->fakeHeadersAsArray);
327+
}
328+
301329
public function testProperlyHandlesRedirectHeaders()
302330
{
303331
$rawHeader = $this->fakeRawRedirectHeader . $this->fakeRawHeader;

0 commit comments

Comments
 (0)