Bug #15693 Updated: HTTP HEAD request executes entire script

From: Date: Sun, 24 Feb 2002 08:57:33 +0000
Subject: Bug #15693 Updated: HTTP HEAD request executes entire script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-892@lists.php.net to get a copy of this message
ID: 15693 Updated by: sander@php.net Reported By: patrick@ginx.com -Status: Open +Status: Bogus Bug Type: HTTP related Operating System: FreeBSD 4.5 PHP Version: 4.1.1 New Comment: A client using HEAD tries to figure out wich HTTP-headers it will receive if it will send GET. Those headers can be generated by your script, so the only way to get those headers is executing your script. If you don't want that, use $_SERVER['REQUEST_METHOD'] or $REQUEST_METHOD to check whether this is a HEAD, GET or POST request. Previous Comments: ------------------------------------------------------------------------ [2002-02-23 18:52:27] patrick@ginx.com Maybe this is the way it's supposed to work, but it doesn't make a whole lot of sense to me. When processing a HEAD request, mod_php executes the script as if it were a normal GET request. This is unexpected (at least to me) and can lead to unexpected results, such as duplicate execution when dealing with browsers that use a HEAD request prior to a GET request. For example, test script test.php: <?php $fp = fopen("test.out", "a"); fputs($fp, "I'm hit!"); fclose($fp); ?> and assuming test.out exists and is world-writable. HEAD /test.php HTTP/1.0 causes the file test.out to be appended to. This is not what I would expect, but maybe it's unavoidable. A workaround is to look at $_SERVER['REQUEST_METHOD'] and do nothing if it's a HEAD request. './configure' '--with-apxs=/usr/local/sbin/apxs' '--with-config-file-path=/usr/local/etc' '--enable-versioning' '--with-system-regex' '--disable-debug' '--enable-track-vars' '--without-gd' '--without-mysql' '--with-zlib' '--with-mcrypt=/usr/local' '--with-mysql=/usr/local' '--prefix=/usr/local' 'i386--freebsd4.5' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15693&edit=1

« previous php.bugs (#892) next »