|
16 | 16 | use Salient\Contract\Curler\CurlerMiddlewareInterface;
|
17 | 17 | use Salient\Contract\Curler\CurlerPageRequestInterface;
|
18 | 18 | use Salient\Contract\Curler\CurlerPagerInterface;
|
19 |
| -use Salient\Contract\Http\Exception\InvalidHeaderException as InvalidHeaderExceptionInterface; |
20 | 19 | use Salient\Contract\Http\Exception\StreamEncapsulationException;
|
21 | 20 | use Salient\Contract\Http\Message\MultipartStreamInterface;
|
22 | 21 | use Salient\Contract\Http\Message\ResponseInterface;
|
@@ -307,12 +306,7 @@ private function responseIsJson(ResponseInterface $response): bool
|
307 | 306 | if (!$headers->hasHeader(self::HEADER_CONTENT_TYPE)) {
|
308 | 307 | return $this->ExpectJson;
|
309 | 308 | }
|
310 |
| - try { |
311 |
| - $contentType = $headers->getOnlyHeaderValue(self::HEADER_CONTENT_TYPE); |
312 |
| - } catch (InvalidHeaderExceptionInterface $ex) { |
313 |
| - $this->debug($ex->getMessage()); |
314 |
| - return false; |
315 |
| - } |
| 309 | + $contentType = $headers->getLastHeaderValue(self::HEADER_CONTENT_TYPE); |
316 | 310 | return HttpUtil::mediaTypeIs($contentType, self::TYPE_JSON);
|
317 | 311 | }
|
318 | 312 |
|
@@ -1139,7 +1133,7 @@ private function getResponse(PsrRequestInterface $request): ResponseInterface
|
1139 | 1133 | }
|
1140 | 1134 |
|
1141 | 1135 | if ($size === null || $size > 0) {
|
1142 |
| - $size ??= Headers::from($request)->getContentLength(); |
| 1136 | + $size ??= HttpUtil::getContentLength($request); |
1143 | 1137 | if ($size !== null && $size <= static::MAX_INPUT_LENGTH) {
|
1144 | 1138 | $body = (string) $body;
|
1145 | 1139 | $opt[\CURLOPT_POSTFIELDS] = $body;
|
@@ -1369,8 +1363,7 @@ static function ($handle, string $data) use (&$bodyIn): int {
|
1369 | 1363 | $redirects !== false
|
1370 | 1364 | && $code >= 300
|
1371 | 1365 | && $code < 400
|
1372 |
| - && count($location = $headersIn->getHeader(self::HEADER_LOCATION)) === 1 |
1373 |
| - && ($location = $location[0]) !== '' |
| 1366 | + && ($location = $headersIn->getOnlyHeaderValue(self::HEADER_LOCATION)) !== '' |
1374 | 1367 | ) {
|
1375 | 1368 | if (!$redirects) {
|
1376 | 1369 | throw new TooManyRedirectsException(sprintf(
|
@@ -1422,7 +1415,7 @@ static function ($handle, string $data) use (&$bodyIn): int {
|
1422 | 1415 | !$this->RetryAfterTooManyRequests
|
1423 | 1416 | || $retrying
|
1424 | 1417 | || $code !== 429
|
1425 |
| - || ($after = $headersIn->getRetryAfter()) === null |
| 1418 | + || ($after = HttpUtil::getRetryAfter($headersIn)) === null |
1426 | 1419 | || ($this->RetryAfterMaxSeconds !== 0 && $after > $this->RetryAfterMaxSeconds)
|
1427 | 1420 | ) {
|
1428 | 1421 | break;
|
|
0 commit comments