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

process the response from a proxy with "HTTP/1.1 200 Connection established" header line #184

Merged
merged 2 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Client/Adapter/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body =

// cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
$responseHeaders = preg_replace(
"/HTTP\/1.0\s*200\s*Connection\s*established\\r\\n\\r\\n/",
"/HTTP\/1.[01]\s*200\s*Connection\s*established\\r\\n\\r\\n/",
'',
$responseHeaders
);
Expand Down
20 changes: 20 additions & 0 deletions test/Client/CurlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,24 @@ public function testTimeoutWithStream()
}
$this->assertNotNull($error, 'Failed to detect timeout in cURL adapter');
}

/**
* @see https://github.com/zendframework/zend-http/pull/184
*
*/
public function testMustRemoveProxyConnectionEstablishedLine()
{
$this->client->setUri($this->baseuri . 'testProxyResponse.php');

$adapter = new Adapter\Curl();

$this->client->setAdapter($adapter);
$this->client->setMethod('GET');
$this->client->send();

$response = $this->client->getResponse();

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('work', $response->getBody());
}
}
8 changes: 8 additions & 0 deletions test/Client/_files/testProxyResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

echo "HTTP/1.1 200 Connection established\r\n\r\n";
echo "HTTP/1.1 200 OK\r\n";
echo "content-type: text/plain;charset=UTF-8\r\n";
echo "server: Server\r\n";
echo "\r\n";
echo "work";