HTTPHeader¶
HTTPHeader(raw_headers)
¶
Represents HTTP headers, preserving order and allowing duplicates.
first(key)
¶
Get the first occurrence of a header by key (case-insensitive).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Header key to search for |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The header value or None if not found |
to_raw()
¶
Convert headers back to raw bytes.
Returns:
| Type | Description |
|---|---|
bytes
|
Raw headers as bytes |
to_dict()
¶
Convert headers to a dictionary. If multiple headers have the same key, only the last one is kept.
Returns:
| Type | Description |
|---|---|
dict
|
Headers as a dictionary |