diff --git a/src/shared/http/CurlHttpClient.php b/src/shared/http/CurlHttpClient.php index 95cfee74..2df728c9 100644 --- a/src/shared/http/CurlHttpClient.php +++ b/src/shared/http/CurlHttpClient.php @@ -74,13 +74,18 @@ public function handleProgressInfo($ch, int $expectedDown, int $received, int $e public function handleHeaderInput($ch, string $line): int { $parts = \explode(':', \trim($line)); - - if (\strtolower($parts[0]) === 'etag') { - $this->etag = new ETag(\trim($parts[1])); + if (!isset($parts[1])) { + return \mb_strlen($line); } - if (\strpos($parts[0], 'X-RateLimit-') !== false) { - $this->rateLimitHeaders[\substr($parts[0], 12)] = \trim($parts[1]); + [$header, $value] = $parts; + $header = \ucfirst(\strtolower($header)); + $value = \trim($value); + + if ($header === 'Etag') { + $this->etag = new ETag($value); + } else if (preg_match('/^(X-)?RateLimit-(.*)$/i', $header, $matches) === 1) { + $this->rateLimitHeaders[$matches[2]] = $value; } return \mb_strlen($line);