6

enter image description here

I'm using Chrome, don't know why some headers in request headers have a colon prefix such as ":method", ":path", while there is no colon prefix in some other headers, what's the point to add a colon prefix for a header, doesn it have a special meaning?

1
  • 1
    These are not HTTP headers. My guess is that this program uses the colon to differentiate information like the method or scheme from headers. Aug 9, 2021 at 14:33

1 Answer 1

5

These are HTTP/2 pseudo-headers that apply to requests and responses within an HTTP/2 stream. HTTP/2 creates a single persistent connection from each distinct origin end-point to a server. That connection transmits multiple requests and responses to and from the end-point; these are parsed into "frames" and transmitted as "streams". HTTP/2 can interleave frames from multiple request and response streams simultaneously to get huge performance benefits. intro to http/2

Pseudo-headers apply to streams; a different set of headers apply to the connection itself. Four pseudo-headers are defined for requests: :method, :scheme, :authority, and :path. No others are allowed. These 4 must be included in every request header block and they must precede any other headers:

"All pseudo-header fields MUST appear in the header block before regular header fields. Any request or response that contains a pseudo-header field that appears in a header block after a regular header field MUST be treated as malformed (Section 8.1.2.6)." http2 spec

Source: https://stackoverflow.com/a/59776597 by HieroB

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .