Skip to content

Commit 5e42d8f

Browse files
committed
always clear response headers between requests
1 parent 2a903cf commit 5e42d8f

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

system/HTTP/CURLRequest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,8 @@ protected function applyBody(array $curlOptions = []): array
469469
*/
470470
protected function setResponseHeaders(array $headers = [])
471471
{
472-
if ($this->shareOptions === false) {
473-
foreach ($this->response->headers() as $header) {
474-
$this->response->removeHeader($header->getName());
475-
}
472+
foreach ($this->response->headers() as $header) {
473+
$this->response->removeHeader($header->getName());
476474
}
477475

478476
foreach ($headers as $header) {

tests/system/HTTP/CURLRequestTest.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,15 +749,15 @@ public function testSendContinuedWithManyHeaders()
749749
$this->assertSame('<title>Update success! config</title>', $response->getBody());
750750

751751
$responseHeaderKeys = [
752-
'Cache-Control',
753-
'Content-Type',
754752
'Server',
755753
'Connection',
756754
'Keep-Alive',
757755
'Set-Cookie',
758756
'Date',
759757
'Expires',
758+
'Cache-Control',
760759
'Pragma',
760+
'Content-Type',
761761
'Transfer-Encoding',
762762
];
763763
$this->assertSame($responseHeaderKeys, array_keys($response->headers()));
@@ -780,19 +780,19 @@ public function testResponseHeadersWithMultipleRequests()
780780
Cache-Control: no-store, no-cache, must-revalidate
781781
Pragma: no-cache
782782
Content-Type: application/xml; charset=utf-8
783-
Transfer-Encoding: chunked\x0d\x0a\x0d\x0a<title>Hello</title>";
783+
Transfer-Encoding: chunked\x0d\x0a\x0d\x0a<title>Hello1</title>";
784784
$request->setOutput($output);
785785

786-
$response = $request->get('answer');
786+
$response = $request->get('answer1');
787787

788-
$this->assertSame('<title>Hello</title>', $response->getBody());
788+
$this->assertSame('<title>Hello1</title>', $response->getBody());
789789

790790
$responseHeaderKeys = [
791-
'Cache-Control',
792-
'Content-Type',
793791
'Server',
794792
'Expires',
793+
'Cache-Control',
795794
'Pragma',
795+
'Content-Type',
796796
'Transfer-Encoding',
797797
];
798798
$this->assertSame($responseHeaderKeys, array_keys($response->headers()));
@@ -803,19 +803,17 @@ public function testResponseHeadersWithMultipleRequests()
803803
Server: ddos-guard
804804
Expires: Thu, 19 Nov 1982 08:52:00 GMT
805805
Content-Type: application/xml; charset=utf-8
806-
Transfer-Encoding: chunked\x0d\x0a\x0d\x0a<title>Hello</title>";
806+
Transfer-Encoding: chunked\x0d\x0a\x0d\x0a<title>Hello2</title>";
807807
$request->setOutput($output);
808808

809-
$response = $request->get('answer');
809+
$response = $request->get('answer2');
810810

811-
$this->assertSame('<title>Hello</title>', $response->getBody());
811+
$this->assertSame('<title>Hello2</title>', $response->getBody());
812812

813813
$responseHeaderKeys = [
814-
'Cache-Control',
815-
'Content-Type',
816814
'Server',
817815
'Expires',
818-
'Pragma',
816+
'Content-Type',
819817
'Transfer-Encoding',
820818
];
821819
$this->assertSame($responseHeaderKeys, array_keys($response->headers()));

user_guide_src/source/changelogs/v4.3.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Deprecations
2727
Bugs Fixed
2828
**********
2929

30-
- **CURLRequest:** Clear response headers between requests when ``Config\CURLRequest::$shareOptions`` is disabled.
30+
- **CURLRequest:** Clear response headers between requests.
3131

3232
See the repo's
3333
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)