Merge pull request #9414 from nupplaphil/bug/guzzle

Fix GuzzleHttpClient
This commit is contained in:
Michael Vogel 2020-10-11 22:02:44 +02:00 committed by GitHub
commit 7a8baf1eea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,11 +102,17 @@ class HTTPRequest implements IHTTPRequest
// $curlOptions[CURLOPT_MAXREDIRS] = 5; // $curlOptions[CURLOPT_MAXREDIRS] = 5;
if (!empty($opts['accept_content'])) { if (!empty($opts['accept_content'])) {
$curlOptions[CURLOPT_HTTPHEADER][] = ['Accept: ' . $opts['accept_content']]; if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
$curlOptions[CURLOPT_HTTPHEADER] = [];
}
array_push($curlOptions[CURLOPT_HTTPHEADER], 'Accept: ' . $opts['accept_content']);
} }
if (!empty($opts['header'])) { if (!empty($opts['header'])) {
$curlOptions[CURLOPT_HTTPHEADER][] = $opts['header']; if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
$curlOptions[CURLOPT_HTTPHEADER] = [];
}
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['header'], $curlOptions[CURLOPT_HTTPHEADER]);
} }
$curlOptions[CURLOPT_RETURNTRANSFER] = true; $curlOptions[CURLOPT_RETURNTRANSFER] = true;
@ -124,7 +130,10 @@ class HTTPRequest implements IHTTPRequest
$curlOptions[CURLOPT_ENCODING] = ''; $curlOptions[CURLOPT_ENCODING] = '';
if (!empty($opts['headers'])) { if (!empty($opts['headers'])) {
$curlOptions[CURLOPT_HTTPHEADER][] = $opts['headers']; if (empty($curlOptions[CURLOPT_HTTPHEADER])) {
$curlOptions[CURLOPT_HTTPHEADER] = [];
}
$curlOptions[CURLOPT_HTTPHEADER] = array_merge($opts['headers'], $curlOptions[CURLOPT_HTTPHEADER]);
} }
if (!empty($opts['nobody'])) { if (!empty($opts['nobody'])) {
@ -191,11 +200,12 @@ class HTTPRequest implements IHTTPRequest
'allow_redirect' => [ 'allow_redirect' => [
'max' => 8, 'max' => 8,
'on_redirect' => $onRedirect, 'on_redirect' => $onRedirect,
'on_headers' => $onHeaders,
'track_redirect' => true, 'track_redirect' => true,
'strict' => true, 'strict' => true,
'referer' => true, 'referer' => true,
], ],
'on_headers' => $onHeaders,
'sink' => tempnam(get_temppath(), 'guzzle'),
'curl' => $curlOptions 'curl' => $curlOptions
]); ]);