http
http copied to clipboard
Helper for parsing headers attributes
I'm missing a helper for parsing headers, i.e something that turns attachment; filename="example.php" into [filename => 'example.php']
Can you add it?
@JanTvrdik Is there a standard for this? I haven't looked myself.
Shouldn't it be more something like [attachment => NULL, filename => 'example.php'] ?
I'll, try to send PR today.
Is there a standard for this?
It depends afaik. There is standard for Accept headers as well as Content-Type header (RFC 7231) at least.
It's not in one place, but if summarized, it leads to http://search.cpan.org/~ether/HTTP-Message-6.11/lib/HTTP/Headers/Util.pm
Uf, as it turned out there is no unified standard (as pointed out for example here). So I guess we need to pick a list of headers which we actually want to be able to parse decide based on that.
The stuff is so fucked up that even browsers don't implement it correctly http://greenbytes.de/tech/tc/httpcontenttype/
Related links (so I don't have to look for them again)
- http://php.net/manual/it/function.http-parse-params.php
- https://mdref.m6w6.name/http/Params
- http://search.cpan.org/~ether/HTTP-Message-6.11/lib/HTTP/Headers/Util.pm
- https://www.gnu.org/software/guile/docs/docs-2.0/guile-ref/HTTP-Headers.html
- https://tools.ietf.org/html/rfc5234#appendix-B.1
- https://tools.ietf.org/html/rfc7230#appendix-B
- https://tools.ietf.org/html/rfc7231#section-3.1.1.5
- http://www.iana.org/assignments/http-parameters/http-parameters.xhtml
- https://www.ietf.org/proceedings/81/slides/httpbis-2.pdf
I like an idea. Any progress here?