Skip to content

Commit

Permalink
Allow Explicit content length on HEAD requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonbennett committed Mar 3, 2022
1 parent e27cfcd commit 8012be0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Io/StreamingServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ public function handleResponse(ConnectionInterface $connection, ServerRequestInt
if (($method === 'CONNECT' && $code >= 200 && $code < 300) || ($code >= 100 && $code < 200) || $code === Response::STATUS_NO_CONTENT) {
// 2xx response to CONNECT and 1xx and 204 MUST NOT include Content-Length or Transfer-Encoding header
$response = $response->withoutHeader('Content-Length');
} elseif ($request->getMethod() === 'HEAD' && $response->hasHeader('Content-Length')) {
// HEAD Request: preserve explicit Content-Length
} elseif ($code === Response::STATUS_NOT_MODIFIED && ($response->hasHeader('Content-Length') || $body->getSize() === 0)) {
// 304 Not Modified: preserve explicit Content-Length and preserve missing header if body is empty
} elseif ($body->getSize() !== null) {
Expand Down

0 comments on commit 8012be0

Please sign in to comment.