Documentation
¶
Overview ¶
Package headerlookup answers, for a caller holding a fiber.Ctx, the two questions the byte-exact header API cannot: whether the stored field names are canonical, and what a named request header holds if they are not.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Canonical ¶
Canonical reports whether fasthttp normalized this request's header names.
fasthttp keeps the answer private, so take it from the app config that set it. This answers for the request store only: a proxied response is parsed by an outbound fasthttp.Client carrying its own setting.
func Combined ¶
Combined returns the named request header as the one value RFC 9110 §5.3 gives a field carried on several lines: their values in the order received, separated by ", ".
This is for a caller naming a field it does not choose — extractors take the name from the application's config, and Accept, Forwarded and the rest are list fields a peer may legally send twice. Value's refusal is wrong for them, because two lines there are one value, not two answers. Where the field is a single value the combination is still not one: a credential joined with another does not match the one that was issued, so a caller comparing it refuses, which is the outcome Value reaches directly.
func Value ¶
Value returns the named request header, matching the field name case-insensitively (RFC 9110 §5.1). Ctx.Get is byte-exact, so a lower-case "origin:" read as absent and the CSRF check found nothing to verify.
ok is false where the message carries the field more than once, whatever the lines are spelled like or hold. Every caller here reads a field defined as a single value — Origin, Referer, Sec-Fetch-Site, Authorization — for which RFC 9110 §5.2 says a sender must not generate a second line at all, so such a message is malformed and what it means is not a question with an answer. Answering with any one of the lines lets whoever wrote the other one decide: picking the first hides a value behind an empty line, and picking the first non-empty defeats a middleware that cleared the field while a differently spelled line from the client remained.
ok is true for a single line that is present and empty, which is not ambiguous — it says the field holds nothing, and "" is that answer.
A caller must not read a false ok as an absent header: absent is a state these fields are allowed to be in and some checks skip themselves for it, which is the opposite of what a malformed message should get. Refuse instead. The value is empty whenever ok is false, so a caller that only refuses empty values still fails closed.
Types ¶
This section is empty.