http icon indicating copy to clipboard operation
http copied to clipboard

Helper for parsing headers attributes

Open JanTvrdik opened this issue 9 years ago • 7 comments

I'm missing a helper for parsing headers, i.e something that turns attachment; filename="example.php" into [filename => 'example.php']

JanTvrdik avatar May 01 '16 10:05 JanTvrdik

Can you add it?

dg avatar May 01 '16 10:05 dg

@JanTvrdik Is there a standard for this? I haven't looked myself.

Shouldn't it be more something like [attachment => NULL, filename => 'example.php'] ?

fprochazka avatar May 01 '16 12:05 fprochazka

I'll, try to send PR today.

JanTvrdik avatar May 01 '16 17:05 JanTvrdik

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.

Majkl578 avatar May 01 '16 20:05 Majkl578

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

JanTvrdik avatar May 01 '16 20:05 JanTvrdik

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

JanTvrdik avatar May 01 '16 22:05 JanTvrdik

I like an idea. Any progress here?

f3l1x avatar Jan 24 '17 13:01 f3l1x