php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43922 CURL HEAD command problem
Submitted: 2008-01-23 17:59 UTC Modified: 2008-02-06 08:15 UTC
From: dragos dot matachescu at dna dot ro Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dragos dot matachescu at dna dot ro
New email:
PHP Version: OS:

 

 [2008-01-23 17:59 UTC] dragos dot matachescu at dna dot ro
Description:
------------
This bug is not solved:

Bug #27341 CURLOPT_CUSTOMREQUEST 'HEAD' misbehaves? 

I checked with latest CVS version

I dont know what you have solved, but the real issus is this: when calling using CURL IIS servers, those servers will return (correctly) in the HEAD method reply the Content-Length field. This is OK because the HTTP protocol says HEAD should be identical with GET, only the body of the response should not be sent in case of HEAD. Apache in case of a HEAD command will NOT return Content-Length in response, so dont test against Apache and say it works. So, if Content-Length is present in a HEAD response, CURL will block waiting to receive o response body of the given length, and this will never come. See below script to reproduce the problem (is the script you proposed at Bug #27341 resolution, only URL is modified to call an IIS server)

Reproduce code:
---------------
<?php 
$ch = curl_init('http://www.robertoswinds.com/store/p.asp?c=126'); //MAKE SURE URL HERE IS FROM A IIS SERVER. THIS IS, I KNOW IT BECAUSE IS MY SERVER.
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); 
var_dump(curl_exec($ch)); 
?>

Expected result:
----------------
return the page content

Actual result:
--------------
HTTP/1.1 200 OK
Date: Wed, 23 Jan 2008 17:49:20 GMT
Server: Microsoft-IIS/6.0
Content-Length: 16914
Content-Type: text/html
Set-Cookie: ASPSESSIONIDSSCDDQSS=NFLPAACDIBKLHIGINKELONCJ; path=/
Cache-control: private

<br />
<b>Fatal error</b>:  Maximum execution time of 30 seconds exceeded in <b>C:\wamp\www\hub\p.php</b> on line <b>5</b><br />


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-05 22:47 UTC] daniel at haxx dot se
Correct, this is the expected and designed behaviour as you're doing a GET request but changes the method keyword to "HEAD" which doesn't make libcurl act differently. It will still act like it does a GET. You get what you ask for.

The NOBODY option is for changing a GET to HEAD and make libcurl treat it as such.

So: thisisnotabug
 [2008-02-06 08:15 UTC] derick@php.net
Thanks Daniel
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC