Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e221bfd

Browse filesBrowse files
committed
Merge branch '6.4' into 7.1
* 6.4: reject URLs containing whitespaces Update validators.fa.xlf [HttpClient] Fix a typo in NoPrivateNetworkHttpClient
2 parents 817b619 + 88898d8 commit e221bfd
Copy full SHA for e221bfd

File tree

Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed

‎NoPrivateNetworkHttpClient.php

Copy file name to clipboardExpand all lines: NoPrivateNetworkHttpClient.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function request(string $method, string $url, array $options = []): Respo
138138
$filterContentHeaders = static function ($h) {
139139
return 0 !== stripos($h, 'Content-Length:') && 0 !== stripos($h, 'Content-Type:') && 0 !== stripos($h, 'Transfer-Encoding:');
140140
};
141-
$options['header'] = array_filter($options['header'], $filterContentHeaders);
141+
$options['headers'] = array_filter($options['headers'], $filterContentHeaders);
142142
$redirectHeaders['no_auth'] = array_filter($redirectHeaders['no_auth'], $filterContentHeaders);
143143
$redirectHeaders['with_auth'] = array_filter($redirectHeaders['with_auth'], $filterContentHeaders);
144144
}

‎Tests/NoPrivateNetworkHttpClientTest.php

Copy file name to clipboardExpand all lines: Tests/NoPrivateNetworkHttpClientTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,27 @@ public function testNonCallableOnProgressCallback()
173173
$client->request('GET', $url, ['on_progress' => $customCallback]);
174174
}
175175

176+
public function testHeadersArePassedOnRedirect()
177+
{
178+
$ipAddr = '104.26.14.6';
179+
$url = sprintf('http://%s/', $ipAddr);
180+
$content = 'foo';
181+
182+
$callback = function ($method, $url, $options) use ($content): MockResponse {
183+
$this->assertArrayHasKey('headers', $options);
184+
$this->assertNotContains('content-type: application/json', $options['headers']);
185+
$this->assertContains('foo: bar', $options['headers']);
186+
return new MockResponse($content);
187+
};
188+
$responses = [
189+
new MockResponse('', ['http_code' => 302, 'redirect_url' => 'http://104.26.14.7']),
190+
$callback,
191+
];
192+
$client = new NoPrivateNetworkHttpClient(new MockHttpClient($responses));
193+
$response = $client->request('POST', $url, ['headers' => ['foo' => 'bar', 'content-type' => 'application/json']]);
194+
$this->assertEquals($content, $response->getContent());
195+
}
196+
176197
private function getMockHttpClient(string $ipAddr, string $content)
177198
{
178199
return new MockHttpClient(new MockResponse($content, ['primary_ip' => $ipAddr]));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.