php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73425 get_headers() and default GET requests
Submitted: 2016-10-31 05:34 UTC Modified: 2021-08-19 13:35 UTC
Votes:2
Avg. Score:2.5 ± 1.5
Reproduced:0 of 1 (0.0%)
From: spam2 at rhsoft dot net Assigned: cmb (profile)
Status: Closed Package: Performance problem
PHP Version: 7.0.12 OS:
Private report: No CVE-ID: None
 [2016-10-31 05:34 UTC] spam2 at rhsoft dot net
Description:
------------
"By default get_headers uses a GET request" is not common sense especially when you can only change that with stream_context_set_default() other than file_get_contents which has a context param

what's the point of that insane default while no server refuses HEAD requests which are logical here by the functions name and behavior - even a httpd with <Limit GET POST> won't refuse HEAD-requests, ours are configzred that way

and no, please don't come with identical behavior and using stream wrappers for everything, when soemone wants to do that he can just achieve the same with file_get_contents which has in fact even a sane context param

what someone expects froma function called get_headers() is, well, just fetch the headers and not the body which is thrown away and if one implements such a unexpetable default it's not enough that you need to *scroll down* in teh documentation to find that out - common sense and least surprise


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-25 16:59 UTC] cmb@php.net
FWIW, as of PHP 7.1.0, get_headers() supports an optional $context
argument.
 [2018-03-25 17:13 UTC] spam2 at rhsoft dot net
cool, thanks

whoever is adapting the manual shoul also think about the other languages and *at least* adopt the params and types on top (it's not the only function which is lacking basic infos like params over time and even wrong types are in general only fixed for the english version)

http://php.net/manual/en/function.get-headers.php
http://php.net/manual/de/function.get-headers.php
 [2018-03-25 21:23 UTC] cmb@php.net
> it's not the only function which is lacking basic infos like
> params over time and even wrong types are in general only fixed
> for the english version

Well, the English docs are the reference, so they are written,
fixed and updated first.  The respective translation teams are
supposed to "sync with EN" as soon as time permits.  It would be
good if the translations pointed out whether they are outdated,
but unfortunately PhD does not support that yet.  Anyhow, many
translations could need some help (the German translation
certainly does!), so consider to submit patches via
<https://edit.php.net/>.

FTR: the $context parameter has been documented[1], and the German
translation has been synced[2].

[1] <http://svn.php.net/viewvc?view=revision&revision=344567>
[2] <http://svn.php.net/viewvc?view=revision&revision=344568>
 [2021-08-19 13:26 UTC] cmb@php.net
-Status: Open +Status: Closed -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: cmb
 [2021-08-19 13:26 UTC] cmb@php.net
> what's the point of that insane default while no server refuses
> HEAD requests

Can you prove your claim? ;)

Anyhow, this is not a bug, but rather a feature request, and
because a $context parameter is available as of PHP 7.1.0, I
consider it sufficiently fulfilled.

I'm not claiming that GET is a particularly reasonable default
here, but changing the long standing default would require the RFC
process[1]; feel free to pursue it.

[1] <https://wiki.php.net/rfc/howto>
 [2021-08-19 13:28 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
> Can you prove your claim? ;)

easily: try to limit methods in httpd to GET/POST and HEAD will still work
it's nonsense to fetch the body when you are only interested in the headers
 [2021-08-19 13:35 UTC] cmb@php.net
$ curl -I https://design.google.com/icons/
HTTP/1.1 405 Method Not Allowed
 [2021-08-19 13:42 UTC] rtrtrtrtrt at dfdfdfdf dot dfd
what insane idiots breaking ETAG / "Not Modified"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC