Re: PHP build-in HTTP server and the HEAD method

From: Date: Wed, 12 Sep 2012 11:44:45 +0000
Subject: Re: PHP build-in HTTP server and the HEAD method
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-62956@lists.php.net to get a copy of this message
On 12/09/12 11:15, Damien Tournoud wrote:
On Wed, Sep 12, 2012 at 10:54 AM, Ivan Enderlin @ Hoa <ivan.enderlin@hoa-project.net> wrote:
Hello, It is probably me but it seems like the build-in HTTP server does not well support the HEAD method. Here is my following test case. First, the foo.php file:
    <?php
    var_dump($_SERVER['REQUEST_METHOD']);
By definition, a HEAD request MUST NOT return a message-body. Oh grrr, I feel stupid now ;-). I forget this.
This works as expected: <?php header("X-Request-Method: " . $_SERVER["REQUEST_METHOD"]); ?> Here is how it works: main/SAPI.c has code that set SG(request_info).headers_only = 1 for HEAD requests, and as a consequence php_request_shutdown() does not flush the output buffer (if any) to the client. Ok.
You can force a body to be sent (but that's likely not going to work with every SAPI) by not having an output buffer or by calling ob_end_flush() yourself. Yes but that was not my goal.
Thank you for your reply :-). -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/

« previous php.internals (#62956) next »