@@ -77,12 +77,12 @@ public function request(string $method, string $url, array $options = []): Respo
77
77
$ options ['body ' ] = self ::getBodyAsString ($ options ['body ' ]);
78
78
79
79
if ('' !== $ options ['body ' ] && 'POST ' === $ method && !isset ($ options ['headers ' ]['content-type ' ])) {
80
- $ options ['raw_headers ' ][] = 'content-type: application/x-www-form-urlencoded ' ;
80
+ $ options ['request_headers ' ][] = 'content-type: application/x-www-form-urlencoded ' ;
81
81
}
82
82
83
83
if ($ gzipEnabled = \extension_loaded ('zlib ' ) && !isset ($ options ['headers ' ]['accept-encoding ' ])) {
84
84
// gzip is the most widely available algo, no need to deal with deflate
85
- $ options ['raw_headers ' ][] = 'accept-encoding: gzip ' ;
85
+ $ options ['request_headers ' ][] = 'accept-encoding: gzip ' ;
86
86
}
87
87
88
88
if ($ options ['peer_fingerprint ' ]) {
@@ -94,7 +94,7 @@ public function request(string $method, string $url, array $options = []): Respo
94
94
}
95
95
96
96
$ info = [
97
- 'raw_headers ' => [],
97
+ 'response_headers ' => [],
98
98
'url ' => $ url ,
99
99
'error ' => null ,
100
100
'http_method ' => $ method ,
@@ -159,7 +159,7 @@ public function request(string $method, string $url, array $options = []): Respo
159
159
[$ host , $ port , $ url ['authority ' ]] = self ::dnsResolve ($ url , $ this ->multi , $ info , $ onProgress );
160
160
161
161
if (!isset ($ options ['headers ' ]['host ' ])) {
162
- $ options ['raw_headers ' ][] = 'host: ' .$ host .$ port ;
162
+ $ options ['request_headers ' ][] = 'host: ' .$ host .$ port ;
163
163
}
164
164
165
165
$ context = [
@@ -203,7 +203,7 @@ public function request(string $method, string $url, array $options = []): Respo
203
203
204
204
$ resolveRedirect = self ::createRedirectResolver ($ options , $ host , $ proxy , $ noProxy , $ info , $ onProgress );
205
205
$ context = stream_context_create ($ context , ['notification ' => $ notification ]);
206
- self ::configureHeadersAndProxy ($ context , $ host , $ options ['raw_headers ' ], $ proxy , $ noProxy );
206
+ self ::configureHeadersAndProxy ($ context , $ host , $ options ['request_headers ' ], $ proxy , $ noProxy );
207
207
208
208
return new NativeResponse ($ this ->multi , $ context , implode ('' , $ url ), $ options , $ gzipEnabled , $ info , $ resolveRedirect , $ onProgress );
209
209
}
@@ -326,12 +326,12 @@ private static function createRedirectResolver(array $options, string $host, ?ar
326
326
$ redirectHeaders = [];
327
327
if (0 < $ maxRedirects = $ options ['max_redirects ' ]) {
328
328
$ redirectHeaders = ['host ' => $ host ];
329
- $ redirectHeaders ['with_auth ' ] = $ redirectHeaders ['no_auth ' ] = array_filter ($ options ['raw_headers ' ], static function ($ h ) {
329
+ $ redirectHeaders ['with_auth ' ] = $ redirectHeaders ['no_auth ' ] = array_filter ($ options ['request_headers ' ], static function ($ h ) {
330
330
return 0 !== stripos ($ h , 'Host: ' );
331
331
});
332
332
333
333
if (isset ($ options ['headers ' ]['authorization ' ]) || isset ($ options ['headers ' ]['cookie ' ])) {
334
- $ redirectHeaders ['no_auth ' ] = array_filter ($ options ['raw_headers ' ], static function ($ h ) {
334
+ $ redirectHeaders ['no_auth ' ] = array_filter ($ options ['request_headers ' ], static function ($ h ) {
335
335
return 0 !== stripos ($ h , 'Authorization: ' ) && 0 !== stripos ($ h , 'Cookie: ' );
336
336
});
337
337
}
@@ -376,46 +376,46 @@ private static function createRedirectResolver(array $options, string $host, ?ar
376
376
377
377
if (false !== (parse_url ($ location , PHP_URL_HOST ) ?? false )) {
378
378
// Authorization and Cookie headers MUST NOT follow except for the initial host name
379
- $ rawHeaders = $ redirectHeaders ['host ' ] === $ host ? $ redirectHeaders ['with_auth ' ] : $ redirectHeaders ['no_auth ' ];
380
- $ rawHeaders [] = 'host: ' .$ host .$ port ;
381
- self ::configureHeadersAndProxy ($ context , $ host , $ rawHeaders , $ proxy , $ noProxy );
379
+ $ requestHeaders = $ redirectHeaders ['host ' ] === $ host ? $ redirectHeaders ['with_auth ' ] : $ redirectHeaders ['no_auth ' ];
380
+ $ requestHeaders [] = 'host: ' .$ host .$ port ;
381
+ self ::configureHeadersAndProxy ($ context , $ host , $ requestHeaders , $ proxy , $ noProxy );
382
382
}
383
383
384
384
return implode ('' , $ url );
385
385
};
386
386
}
387
387
388
- private static function configureHeadersAndProxy ($ context , string $ host , array $ rawHeaders , ?array $ proxy , array $ noProxy )
388
+ private static function configureHeadersAndProxy ($ context , string $ host , array $ requestHeaders , ?array $ proxy , array $ noProxy )
389
389
{
390
390
if (null === $ proxy ) {
391
- return stream_context_set_option ($ context , 'http ' , 'header ' , $ rawHeaders );
391
+ return stream_context_set_option ($ context , 'http ' , 'header ' , $ requestHeaders );
392
392
}
393
393
394
394
// Matching "no_proxy" should follow the behavior of curl
395
395
396
396
foreach ($ noProxy as $ rule ) {
397
397
if ('* ' === $ rule ) {
398
- return stream_context_set_option ($ context , 'http ' , 'header ' , $ rawHeaders );
398
+ return stream_context_set_option ($ context , 'http ' , 'header ' , $ requestHeaders );
399
399
}
400
400
401
401
if ($ host === $ rule ) {
402
- return stream_context_set_option ($ context , 'http ' , 'header ' , $ rawHeaders );
402
+ return stream_context_set_option ($ context , 'http ' , 'header ' , $ requestHeaders );
403
403
}
404
404
405
405
$ rule = '. ' .ltrim ($ rule , '. ' );
406
406
407
407
if (substr ($ host , -\strlen ($ rule )) === $ rule ) {
408
- return stream_context_set_option ($ context , 'http ' , 'header ' , $ rawHeaders );
408
+ return stream_context_set_option ($ context , 'http ' , 'header ' , $ requestHeaders );
409
409
}
410
410
}
411
411
412
412
stream_context_set_option ($ context , 'http ' , 'proxy ' , $ proxy ['url ' ]);
413
413
stream_context_set_option ($ context , 'http ' , 'request_fulluri ' , true );
414
414
415
415
if (null !== $ proxy ['auth ' ]) {
416
- $ rawHeaders [] = 'Proxy-Authorization: ' .$ proxy ['auth ' ];
416
+ $ requestHeaders [] = 'Proxy-Authorization: ' .$ proxy ['auth ' ];
417
417
}
418
418
419
- return stream_context_set_option ($ context , 'http ' , 'header ' , $ rawHeaders );
419
+ return stream_context_set_option ($ context , 'http ' , 'header ' , $ requestHeaders );
420
420
}
421
421
}
0 commit comments