Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-roll pull/302 patch for compatibility with php-vcr 1.5.5. #404

Open
wants to merge 2 commits into
base: 1.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/VCR/Util/HttpUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
unset($headers[$i]);
}

return $headers;

Check failure on line 33 in src/VCR/Util/HttpUtil.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method VCR\Util\HttpUtil::parseHeaders() should return array<string, string> but returns array<array<int, string>|string>.
}

/**
Expand Down Expand Up @@ -68,7 +68,7 @@
{
$response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response);

[$rawHeader, $rawBody] = explode("\r\n\r\n", $response, 2);
[$rawHeader, $rawBody] = array_pad(explode("\r\n\r\n", $response, 2), 2, '');

// Parse headers and status.
$headers = self::parseRawHeader($rawHeader);
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/Util/HttpUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
$this->assertEquals($expectedHeaders, $headers);
}

public function testParseResponseNull(): void
{
$raw = null;
[$status, $headers, $body] = HttpUtil::parseResponse($raw);

Check failure on line 48 in tests/Unit/Util/HttpUtilTest.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $response of static method VCR\Util\HttpUtil::parseResponse() expects string, null given.

$expectedHeaders = [];
$this->assertEquals(null, $status);
$this->assertEquals(null, $body);
$this->assertEquals($expectedHeaders, $headers);
}

public function testParseContinuePlusResponse(): void
{
$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";
Expand Down