@@ -28,6 +28,13 @@ class CURLRequest extends OutgoingRequest
2828 */
2929 protected $ response ;
3030
31+ /**
32+ * The original response object associated with this request
33+ *
34+ * @var ResponseInterface|null
35+ */
36+ protected $ responseOrig ;
37+
3138 /**
3239 * The URI associated with this request
3340 *
@@ -105,7 +112,7 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
105112
106113 parent ::__construct ('GET ' , $ uri );
107114
108- $ this ->response = $ response ;
115+ $ this ->responseOrig = $ response ;
109116 $ this ->baseURI = $ uri ->useRawQueryString ();
110117 $ this ->defaultOptions = $ options ;
111118
@@ -125,6 +132,8 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
125132 */
126133 public function request ($ method , string $ url , array $ options = []): ResponseInterface
127134 {
135+ $ this ->response = clone $ this ->responseOrig ;
136+
128137 $ this ->parseOptions ($ options );
129138
130139 $ url = $ this ->prepareURL ($ url );
@@ -469,10 +478,6 @@ protected function applyBody(array $curlOptions = []): array
469478 */
470479 protected function setResponseHeaders (array $ headers = [])
471480 {
472- foreach ($ this ->response ->headers () as $ header ) {
473- $ this ->response ->removeHeader ($ header ->getName ());
474- }
475-
476481 foreach ($ headers as $ header ) {
477482 if (($ pos = strpos ($ header , ': ' )) !== false ) {
478483 $ title = substr ($ header , 0 , $ pos );
0 commit comments