[development] HTTP headers to get the head of the page

Dipen dipench at gmail.com
Sun Dec 6 15:54:06 UTC 2009


Side note: drupal_http_request takes a retry for the very same purpose of
auto follow, but since its defaulted to 3, you should have got the
content-length unless its doing more than 3 redirections.


On Sun, Dec 6, 2009 at 9:21 PM, Dipen <dipench at gmail.com> wrote:

> Hi nitin,
>
>  It would return Content-Length as the main application of using HEAD is
> for proxies to find if the cached copy can be used or not, availability of
> Content-Length is mandatory to do those kind of checks. In any case you must
> be getting a redirection maybe 301, 302 in status code so you would need to
> follow the location.
>
> For example I just tried looking for header info on
> http://facebook.com/login.php and I got a redirection 301 to
> www.facebook.com/login.php and in that location u would receive
> content-length.
>
> I used this tool : http://www.rexswain.com/httpview.html
>
> First try with www.facebook.com/login.php and it would give u
> content-Length in first hit ( do not forget to use HEAD as method type)
>
> Then try with http://facebook.com/login.php and auto follow enabled and
> this time u would get it in the location 2.
>
> Cheers
> Dipen
>
>
>
>
> On Sun, Dec 6, 2009 at 9:08 PM, nitin gupta <nitingupta.iitg at gmail.com>wrote:
>
>> Thanks Dipen, It works perfectly well. Thanks for making me aware of the
>> HEAD method.
>>
>> The headers does not contain "content-length" when invoked on a .php page,
>> is this in accordance with the protocol?
>>
>>
>> --
>> Regards,
>> Nitin Kumar Gupta
>> http://publicmind.in/blog/
>>
>>
>> On Sun, Dec 6, 2009 at 8:46 PM, Dipen <dipench at gmail.com> wrote:
>>
>>> I havent tried it doing it with drupal but try passing method = HEAD.
>>>
>>> HEAD /index.html
>>>
>>> would fetch only headers of that resource, where as GET for instance
>>> would also return the content.
>>>
>>> Cheers
>>> dipen
>>>
>>>
>>>
>>>
>>> On Sun, Dec 6, 2009 at 7:52 PM, nitin gupta <nitingupta.iitg at gmail.com>wrote:
>>>
>>>> Hi,
>>>>
>>>> I am currently using curl (CURLOPT_NOBODY) to exclude the body and to
>>>> just get the headers returned by the sever for a http request. I am
>>>> specifically interested in the return status code and the content length.
>>>> Can I do it using drupal_http_request? What will be the suitable value for
>>>> the $headers, so that I don't need to download the whole page?
>>>>
>>>> http://api.drupal.org/api/function/drupal_http_request/6
>>>>
>>>> --
>>>> Regards,
>>>> Nitin Kumar Gupta
>>>> http://publicmind.in/blog/
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20091206/a85888ea/attachment.html 


More information about the development mailing list