authority http header - in chrome dev tools

HttpGoogle Chrome-Devtools

Http Problem Overview


chrome dev tools - displays some http header with a leading : (not sure why it does with some and not others).

One of these is the http header authority which is displays as:

authority:api.somedomain.com

However this is listed in the list of http headers on Wikipedia. Is this a new HTTP2 header or is possible to define any new request field in the headers -or are these fixed?

Http Solutions


Solution 1 - Http

These are Pseudo-Header Fields defined in the new HTTP/2.

HTTP/1.x used the message start-line to represent target URI, method of request, response code, etc. All HTTP messages are either request from the client to the server or response from the server to the client. These two types are distinguished by their start-line, which is request-line for requests, or status-line for responses.

request-line   = method SP request-target SP HTTP-version CRLF

status-line = HTTP-version SP status-code SP reason-phrase CRLF

You can read more in RFC7230 section 3.1

But HTTP/2 uses special pseudo-header fields beginning with ':' character (ASCII 0x3a) for this purpose. These pseudo-headers are strictly defined. There are request pseudo-header fields and response pseudo-header fields. Request pseudo-header fields are :method, :scheme, :authority, :path.

The ":authority" pseudo-header field includes the authority portion of the target URI.

authority   = [ userinfo "@" ] host [ ":" port ]

Read more in RFC7540.

In HTTP/1.x, it is equivalent with host header field. In RFC7540, some measures are mentioned for backward compatibility with HTTP/1.x

> To ensure that the HTTP/1.1 request line can be reproduced accurately, this pseudo-header field MUST be omitted when translating from an HTTP/1.1 request that has a request target in origin or asterisk form. Clients that generate HTTP/2 requests directly SHOULD use the ":authority" pseudo-header field instead of the Host header field. An intermediary that converts an HTTP/2 request to HTTP/1.1 MUST create a Host header field if one is not present in a request by copying the value of the ":authority" pseudo-header field.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYuntiView Question on Stackoverflow
Solution 1 - HttpSourav GhoshView Answer on Stackoverflow