Skip to content

Commit 4b28261

Browse files
committed
Merge pull request php-vcr#128 from stevemiketa/http-continue-support
Thanks a lot @stevemiketa, I'll merge.
2 parents dfb1869 + 89e384d commit 4b28261

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/VCR/Util/HttpUtil.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public static function parseStatus($status)
6161
*/
6262
public static function parseResponse($response)
6363
{
64+
$response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response);
65+
6466
list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2);
6567

6668
// Parse headers and status.

tests/VCR/Util/HttpUtilTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,59 @@ public function testParseResponseMultipleHeaders()
3939
$this->assertEquals($expectedHeaders, $headers);
4040
}
4141

42+
public function testParseContinuePlusResponse()
43+
{
44+
$raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n";
45+
list($status, $headers, $body) = HttpUtil::parseResponse($raw);
46+
47+
$expectedHeaders = array(
48+
'Content-Type: text/html',
49+
'Date: Fri, 19 Jun 2015 16:05:18 GMT',
50+
'Vary: Accept-Encoding',
51+
'Content-Length: 0'
52+
);
53+
54+
$this->assertEquals('HTTP/1.1 201 Created', $status);
55+
$this->assertEquals(null, $body);
56+
$this->assertEquals($expectedHeaders, $headers);
57+
}
58+
59+
public function testParseiMultipleContinuePlusResponse()
60+
{
61+
$raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n";
62+
list($status, $headers, $body) = HttpUtil::parseResponse($raw);
63+
64+
$expectedHeaders = array(
65+
'Content-Type: text/html',
66+
'Date: Fri, 19 Jun 2015 16:05:18 GMT',
67+
'Vary: Accept-Encoding',
68+
'Content-Length: 0'
69+
);
70+
71+
$this->assertEquals('HTTP/1.1 201 Created', $status);
72+
$this->assertEquals(null, $body);
73+
$this->assertEquals($expectedHeaders, $headers);
74+
}
75+
76+
77+
public function testParseContinuePlusResponseMultipleHeaders()
78+
{
79+
$raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept, Accept-Language, Expect\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n";
80+
list($status, $headers, $body) = HttpUtil::parseResponse($raw);
81+
82+
$expectedHeaders = array(
83+
'Content-Type: text/html',
84+
'Date: Fri, 19 Jun 2015 16:05:18 GMT',
85+
'Vary: Accept, Accept-Language, Expect',
86+
'Vary: Accept-Encoding',
87+
'Content-Length: 0'
88+
);
89+
90+
$this->assertEquals('HTTP/1.1 201 Created', $status);
91+
$this->assertEquals(null, $body);
92+
$this->assertEquals($expectedHeaders, $headers);
93+
}
94+
4295
public function testParseHeadersBasic()
4396
{
4497
$inputArray = array(

0 commit comments

Comments
 (0)