204 response is buffered

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I noticed a change in behavior when going from Apache/2.4.16 to
Apache/2.4.33 when sending a 204 Response that the header
Content-Length 0 is removed by Apache when it is included in 204
Response.

This looks to be the correct behavior based on the RFC spec

https://tools.ietf.org/html/rfc7230#section-3.3.2

“A server MUST NOT send a Content-Length header field in any response
with a status code of 1xx (Informational) or 204 (No Content).”

However, what I am also noticing is a delay in the 204 Response being
sent to the client in Apache/2.4.33.

The use case is that this is a PHP script on the server that is
sending the 204 Response immediately and the continuing to do work.

In Apache/2.4.16 the 204 Response is sent immediately, in
Apache/2.4.33 the response is sent only after the PHP script exits.

My best guess is that the stripping of the Content-Length 0 header is
causing Apache to not flush the socket right away, but it now waits
for the PHP script to exit.

If I send a 200 Response instead, with a Content-Length 0, then there
is no delay in Apache/2.4.33

I checked the bugs database and couldn't find anything, so am checking
here to see if it is maybe an apache bug.

I confirmed the issue still exists in Apache/2.4.41. Below are my
steps to test and the results.

Thanks,

Todd


https://github.com/docker-library/php/tree/master/7.4/buster/apache

changed debian:buster-slim to debian:unstable-slim to get latest apache

docker build -t php-docker-apache-example .

docker run -d -p 8080:80 php-docker-apache-example

First experiment,  returning 204

php.index

<?php
header("HTTP/1.1 204 No Content");
        ob_end_clean();

        header('Connection: close');
        ob_start();
        $size = ob_get_length();
        header("Content-Length: $size");
        ob_end_flush();
        flush();
sleep(5);
exit;
?>


~/php-docker-apache-example $ time curl -v http://127.0.0.1:8080
* Rebuilt URL to: http://127.0.0.1:8080/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 204 No Content
< Date: Thu, 06 Feb 2020 14:22:36 GMT
< Server: Apache/2.4.41 (Debian)
< X-Powered-By: PHP/7.4.2
< Connection: close
<
* Closing connection 0

real 0m5.020s
user 0m0.005s
sys 0m0.007s


and the apache logs for that are

$ docker logs --follow
62046b36868209242de8cf681f0711f811a86ffa5adf66c31865928204acdbe9
AH00558: apache2: Could not reliably determine the server's fully
qualified domain name, using 172.17.0.2. Set the 'ServerName'
directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully
qualified domain name, using 172.17.0.2. Set the 'ServerName'
directive globally to suppress this message
[Thu Feb 06 14:37:27.367142 2020] [mpm_prefork:notice] [pid 1]
AH00163: Apache/2.4.41 (Debian) PHP/7.4.2 configured -- resuming
normal operations
[Thu Feb 06 14:37:27.367234 2020] [core:notice] [pid 1] AH00094:
Command line: 'apache2 -D FOREGROUND'
172.17.0.1 - - [06/Feb/2020:14:37:59 +0000] "GET / HTTP/1.1" 204 140
"-" "curl/7.54.0"


Second experiment, returning 200 Response

index.php

<?php
header("HTTP/1.1 200 OK");
        ob_end_clean();

        header('Connection: close');
        ob_start();
        $size = ob_get_length();
        header("Content-Length: $size");
        ob_end_flush();
        flush();
sleep(5);
exit;
?>


~/php-docker-apache-example $ time curl -v http://127.0.0.1:8080
* Rebuilt URL to: http://127.0.0.1:8080/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 06 Feb 2020 14:26:29 GMT
< Server: Apache/2.4.41 (Debian)
< X-Powered-By: PHP/7.4.2
< Connection: close
< Content-Length: 0
< Vary: Accept-Encoding
< Content-Type: text/html; charset=UTF-8
<
* Closing connection 0

real 0m0.026s
user 0m0.005s
sys 0m0.008s

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx





[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux