Zag zag..
Zag zag..

Reputation: 6231

Possible types of a HTTP header value

The type of a value passed through a query string is always a string. When a HTTP client need to send a number, let's say 42, in is actually "42". Everything inside the query string is actually a string.

Is it the same for the type of values passed through a header ?

In other words, if we send an HTTP request with a "FooBar" header with the value of 42, and another request where the value of the header set to "42", will the server perceive the two received values as of the same type and value (i.e. "42")?

Upvotes: 22

Views: 12692

Answers (2)

oligofren
oligofren

Reputation: 22923

tldr; Headers are text, sometimes ISO 8859, but usually just US-ASCII.

According to the 2014 RFC7230 (last paragraph), HTTP fields have used to be text and new headers should continue to do so, restricting the values to consist of US-ASCII octets.

The 1982 RFC822 specifies ASCII as the format of the header body.

References (found through List of HTTP Headers):

Upvotes: 11

dsign
dsign

Reputation: 12700

It's always a string, even in HTTP/2

Upvotes: 34

Related Questions