Le 4 mai 2021, la plateforme Yahoo Questions/Réponses fermera. Elle est désormais accessible en mode lecture seule. Aucune modification ne sera apportée aux autres sites ou services Yahoo, ni à votre compte Yahoo. Vous trouverez plus d’informations sur l'arrêt de Yahoo Questions/Réponses et sur le téléchargement de vos données sur cette page d'aide.
HTTP Header Content-Length question?
Im capturing traces using WireShark and I have a question about the basic syntax for the items in the header (Content-Length, Accept, Host, etc).
The syntax I see is:
Content-Length: 10/n/r for example
Are the fields case sensitive (must be as above) or can it be:
content-length: 10
Also is the space between the : and the length (10) required or can it be:
Content-Length:10
I need to parse these fields and I need to know this.
1 réponse
- djbckrLv 5il y a 7 ansRéponse favorite
The general rule is that:
- a sender should send well-formed data
- a receiver should accept and parse imperfect data within reason
The headers *should* be in the proper case, then a colon (:) then a space, then the header value. Most sites honor this, but you can't necessarily absolutely rely on it.
So, short answer: accept everything within sensible boundaries.
Examples from W3C: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14....
Examples from Wikipedia: http://en.wikipedia.org/wiki/List_of_HTTP_header_f...