Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 330
Zag zag.. Avatar asked Dec 08 '15 09:12

Zag zag..


People also ask

How many types of HTTP headers are there?

There are four types of HTTP message headers: General-header: These header fields have general applicability for both request and response messages. Client Request-header: These header fields have applicability only for request messages.

What is HTTP header value?

HTTP headers are the name or value pairs that are displayed in the request and response messages of message headers for Hypertext Transfer Protocol (HTTP). Usually, the header name and the value are separated by a single colon. HTTP headers are an integral part of HTTP requests and responses.

Which characters are allowed in an HTTP header value?

The value of the HTTP request header you want to set can only contain: Alphanumeric characters: a - z and A - Z. The following special characters: _ :;.,\/"'?!(){}[]@<>=-+*#$&`|~^%


2 Answers

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

like image 106
dsign Avatar answered Sep 20 '22 06:09

dsign


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

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

  • Section 3.2 of RFC822
  • RFC7230
like image 42
oligofren Avatar answered Sep 19 '22 06:09

oligofren