Skip to content

Commit 1952e0c

Browse files
committed
Check the actual status code for 204 and 304
The header is the full http header like: HTTP/1.1 304 Not Modified So comparing this to an int always yields false This also makes the 304 RFC compliant as the resulting content length should otherwise be the length of the message and not 0. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent 96d1921 commit 1952e0c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/private/AppFramework/App.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,15 @@ public static function main(string $controllerName, string $methodName, DIContai
157157
* https://tools.ietf.org/html/rfc7230#section-3.3
158158
* https://tools.ietf.org/html/rfc7230#section-3.3.2
159159
*/
160-
if ($httpHeaders !== Http::STATUS_NO_CONTENT && $httpHeaders !== Http::STATUS_NOT_MODIFIED) {
160+
$emptyResponse = false;
161+
if (preg_match('/^HTTP\/\d\.\d (\d{3}) .*$/', $httpHeaders, $matches)) {
162+
$status = (int)$matches[1];
163+
if ($status === Http::STATUS_NO_CONTENT || $status === Http::STATUS_NOT_MODIFIED) {
164+
$emptyResponse = true;
165+
}
166+
}
167+
168+
if (!$emptyResponse) {
161169
if ($response instanceof ICallbackResponse) {
162170
$response->callback($io);
163171
} else if (!is_null($output)) {

0 commit comments

Comments
 (0)