23

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")?

1
  • Was wondering this today! Commented Apr 18, 2017 at 19:37

2 Answers 2

36

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

Sign up to request clarification or add additional context in comments.

2 Comments

Reference? I don't see one. I have tried searching, and your answer comes up, but it is hardly authorative.
@dsign I tried doing my research, which landed my here. I was just asking if you had a reference, since I failed to find any, and as I am implicitly responsible for reimplementing parts of the spec I can't just trust some random assertion on the net. But through Wikipedia I was able to find RFC7230. High value answers with all the information one needs is one of the intended goals of SO, so I wasn't trying to offend you :)
11

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):

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.