action0-req 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
action0/req/headers.py ADDED
@@ -0,0 +1,705 @@
1
+ """The :py:class:`Headers` mapping and the known header field names (:py:class:`Header`)."""
2
+
3
+ from enum import StrEnum
4
+ from typing import Iterable
5
+ from typing import Iterator
6
+ from typing import Mapping
7
+ from typing import MutableMapping
8
+ from typing import Union
9
+ from typing import cast
10
+
11
+ HeaderValue = Union[str, int, float, bool]
12
+ """A single header value; non-strings are coerced to strings on the way in
13
+ (bools become the web-style ``"true"`` / ``"false"``)."""
14
+
15
+ # Mapping instead of dict so callers may pass any dict-ish type and, unlike
16
+ # dict, Mapping is covariant in its value type (a dict[str, str] works too)
17
+ HeaderTypes = Union[
18
+ Iterable[tuple[str, Union[HeaderValue, Iterable[HeaderValue]]]],
19
+ Mapping[str, Union[HeaderValue, Iterable[HeaderValue]]],
20
+ str,
21
+ ]
22
+ """Everything that can initialize a :py:class:`Headers` instance: a raw
23
+ header block, a mapping, or an iterable of name/value(s) tuples."""
24
+
25
+
26
+ def _coerce_value(value: HeaderValue) -> str:
27
+ """
28
+ Coerce a single header value to its string representation.
29
+
30
+ :param value: the value to coerce
31
+ :return: the value as a string, bools as "true" / "false"
32
+ """
33
+ # bool before the plain str() fallback: bools use the web convention
34
+ if isinstance(value, bool):
35
+ return "true" if value else "false"
36
+ if isinstance(value, str):
37
+ return value
38
+ return str(value)
39
+
40
+
41
+ def _coerce_values(value_s: Union[HeaderValue, Iterable[HeaderValue]]) -> list[str]:
42
+ """
43
+ Coerce a single value or an iterable of values to a list of strings.
44
+
45
+ :param value_s: a single value or an iterable of values
46
+ :return: all values as a list of strings
47
+ """
48
+ if isinstance(value_s, (str, int, float, bool)):
49
+ return [_coerce_value(value_s)]
50
+ return [_coerce_value(value_) for value_ in value_s]
51
+
52
+
53
+ class Headers(MutableMapping[str, str]):
54
+ r"""
55
+ An ordered, case-insensitive, multi-value aware mapping of HTTP header
56
+ fields. Internally it is a list of ``(name, value)`` lines: the order
57
+ and casing of the representation are preserved exactly, while every
58
+ lookup matches field names case-insensitively (per :rfc:`9110` —
59
+ ``headers["content-type"]`` and ``headers["Content-Type"]`` hit the
60
+ same field). Names are never normalized beyond that; in particular an
61
+ underscore is not treated as a dash.
62
+
63
+ Headers implements :py:class:`typing.MutableMapping`: the mapping view
64
+ (``headers[name]``, :py:meth:`get`, ``items()``, ...) works with a
65
+ single value per name — the last one, like :py:meth:`singles`.
66
+ Multi-value access is available through :py:meth:`get_all`,
67
+ :py:meth:`get_values`, :py:meth:`add`, :py:meth:`as_dict` and
68
+ :py:meth:`as_lines`.
69
+
70
+ Example::
71
+
72
+ >>> headers = Headers({"Content-Type": "text/html"})
73
+ >>> headers.add("Set-Cookie", "a=1")
74
+ >>> headers.add("set-cookie", "b=2")
75
+ >>> headers["content-type"]
76
+ 'text/html'
77
+ >>> headers.get_all("Set-Cookie")
78
+ ['a=1', 'b=2']
79
+ >>> len(headers), "SET-COOKIE" in headers
80
+ (2, True)
81
+ >>> headers.as_str()
82
+ 'Content-Type: text/html\r\nSet-Cookie: a=1\r\nset-cookie: b=2'
83
+
84
+ ``repr()`` (and thus ``str()``) redacts the values of the
85
+ :py:attr:`secret_names` fields; only :py:meth:`as_str` renders them:
86
+
87
+ >>> headers["Authorization"] = "Bearer secret-token"
88
+ >>> headers
89
+ Headers(Content-Type: text/html, Set-Cookie: ***, set-cookie: ***, Authorization: ***)
90
+ """
91
+
92
+ secret_names: frozenset[str] = frozenset(
93
+ {
94
+ "authorization",
95
+ "proxy-authorization",
96
+ "cookie",
97
+ "set-cookie",
98
+ "x-api-key",
99
+ "x-csrf-token",
100
+ }
101
+ )
102
+ """The (casefolded) names of the fields whose values carry secrets and
103
+ are shown as ``***`` by ``repr()``. Override on a subclass or instance
104
+ to redact more (or fewer) fields."""
105
+
106
+ def __init__(self, headers: Union[HeaderTypes, None] = None) -> None:
107
+ r"""
108
+ :param headers: the initial header lines, either as a raw header
109
+ block (lines of ``"Name: value"`` separated by
110
+ ``"\r\n"`` or ``"\n"``; blank lines are skipped,
111
+ obsolete line folding is not supported), another
112
+ Headers instance whose lines are copied, or as a
113
+ list of tuples or a dictionary. The values can be
114
+ single values or lists of values (one line each);
115
+ non-string values are coerced to strings (bools
116
+ become "true" / "false").
117
+ :raises ValueError: if a line of a raw header block has no ``":"``
118
+ """
119
+ self._lines: list[tuple[str, str]] = []
120
+
121
+ if isinstance(headers, Headers):
122
+ self._lines = list(headers._lines)
123
+
124
+ elif isinstance(headers, str):
125
+ for line in headers.splitlines():
126
+ if not line.strip():
127
+ continue
128
+ name, sep, value = line.partition(":")
129
+ if not sep or not name.strip():
130
+ raise ValueError(f"invalid header line: {line!r}")
131
+ self.add(name.strip(), value.strip(" \t"))
132
+
133
+ elif isinstance(headers, Mapping):
134
+ # cast: the type checker cannot fully rule out the Iterable-of-tuples
135
+ # union member here because a Mapping is itself an Iterable
136
+ mapping = cast("Mapping[str, Union[HeaderValue, Iterable[HeaderValue]]]", headers)
137
+ for name, value_s in mapping.items():
138
+ self.add(name, value_s)
139
+
140
+ elif isinstance(headers, Iterable):
141
+ for name, value_s in headers:
142
+ self.add(name, value_s)
143
+
144
+ def __getitem__(self, name: str) -> str:
145
+ """
146
+ The single value of the field; if the field has multiple lines,
147
+ the value of the last one — like :py:meth:`singles`. Use
148
+ :py:meth:`get_all` for all values.
149
+
150
+ :param name: the field name (case-insensitive)
151
+ :return: the (last) value of the field
152
+ :raises KeyError: if the field does not exist
153
+ """
154
+ folded = name.casefold()
155
+ for line_name, value in reversed(self._lines):
156
+ if line_name.casefold() == folded:
157
+ return value
158
+ raise KeyError(name)
159
+
160
+ def __setitem__(self, name: str, value: Union[HeaderValue, Iterable[HeaderValue]]) -> None:
161
+ """
162
+ Replace all lines of the field, same as :py:meth:`set`.
163
+
164
+ :param name: the field name (case-insensitive)
165
+ :param value: a single value or a list of values (one line each)
166
+ """
167
+ self.set(name, value)
168
+
169
+ def __delitem__(self, name: str) -> None:
170
+ """
171
+ Remove the field with all its lines.
172
+
173
+ :param name: the field name (case-insensitive)
174
+ :raises KeyError: if the field does not exist
175
+ """
176
+ if not self.remove(name):
177
+ raise KeyError(name)
178
+
179
+ def __iter__(self) -> Iterator[str]:
180
+ """
181
+ :return: an iterator over the distinct field names in the order of
182
+ their first line, each in the casing of that first line
183
+ """
184
+ seen: set[str] = set()
185
+ for name, _ in self._lines:
186
+ folded = name.casefold()
187
+ if folded not in seen:
188
+ seen.add(folded)
189
+ yield name
190
+
191
+ def __len__(self) -> int:
192
+ """
193
+ :return: the number of distinct field names
194
+ """
195
+ return len({name.casefold() for name, _ in self._lines})
196
+
197
+ def __contains__(self, name: object) -> bool:
198
+ """
199
+ :param name: the field name (case-insensitive)
200
+ :return: whether a field with this name exists
201
+ """
202
+ if not isinstance(name, str):
203
+ return False
204
+ folded = name.casefold()
205
+ return any(line_name.casefold() == folded for line_name, _ in self._lines)
206
+
207
+ def get_all(self, name: str) -> list[str]:
208
+ """
209
+ The values of all lines of the field, in representation order; use
210
+ ``headers[name]`` or :py:meth:`get` for the single-value view and
211
+ :py:meth:`get_values` for the comma-split element view.
212
+
213
+ :param name: the field name (case-insensitive)
214
+ :return: the values as a list, an empty list if the field does
215
+ not exist
216
+ """
217
+ folded = name.casefold()
218
+ return [value for line_name, value in self._lines if line_name.casefold() == folded]
219
+
220
+ def get_values(self, name: str) -> list[str]:
221
+ """
222
+ The elements of all lines of the field: like :py:meth:`get_all`,
223
+ but each line is additionally split on ``","`` (:rfc:`9110` list
224
+ syntax) with whitespace stripped and empty elements dropped.
225
+
226
+ WARNING: ``Set-Cookie`` does not use the list syntax — its values
227
+ may contain literal commas (e.g. in an ``Expires`` attribute), so
228
+ use :py:meth:`get_all` for it.
229
+
230
+ :param name: the field name (case-insensitive)
231
+ :return: the elements as a list, an empty list if the field does
232
+ not exist
233
+ """
234
+ return [
235
+ element.strip(" \t")
236
+ for line in self.get_all(name)
237
+ for element in line.split(",")
238
+ if element.strip(" \t")
239
+ ]
240
+
241
+ def add(self, name: str, value: Union[HeaderValue, Iterable[HeaderValue]]) -> None:
242
+ """
243
+ Append a line for each given value at the end, keeping existing
244
+ lines of the field.
245
+
246
+ :param name: the field name to add (stored in the given casing)
247
+ :param value: the value or list of values to add (one line each)
248
+ """
249
+ self._lines.extend((name, value_) for value_ in _coerce_values(value))
250
+
251
+ def remove(
252
+ self, name: str, value: Union[HeaderValue, Iterable[HeaderValue], None] = None
253
+ ) -> list[str]:
254
+ """
255
+ If only a name is given all lines of this field are removed. If a
256
+ value or a list of values is given only the matching lines are
257
+ removed.
258
+
259
+ :param name: the name of the field to remove (or from which lines
260
+ are to be removed), case-insensitive
261
+ :param value: if given, only lines with matching value(s) are to be
262
+ removed, not the entire field
263
+ :return: a list of removed values
264
+ """
265
+ folded = name.casefold()
266
+ value_list = None if value is None else _coerce_values(value)
267
+
268
+ kept: list[tuple[str, str]] = []
269
+ removed: list[str] = []
270
+ for line_name, line_value in self._lines:
271
+ if line_name.casefold() == folded and (value_list is None or line_value in value_list):
272
+ removed.append(line_value)
273
+ else:
274
+ kept.append((line_name, line_value))
275
+
276
+ self._lines = kept
277
+ return removed
278
+
279
+ def set(self, name: str, value: Union[HeaderValue, Iterable[HeaderValue]]) -> None:
280
+ """
281
+ Replace all lines of the field with the value(s) given, at the
282
+ position of the field's first line (new fields are appended at the
283
+ end). Setting an empty list of values removes the field.
284
+
285
+ :param name: the field name (matched case-insensitively, stored in
286
+ the given casing)
287
+ :param value: a single value or a list of values (one line each)
288
+ """
289
+ values = _coerce_values(value)
290
+ if not values:
291
+ self.remove(name)
292
+ return
293
+
294
+ folded = name.casefold()
295
+ new_lines: list[tuple[str, str]] = []
296
+ inserted = False
297
+ for line_name, line_value in self._lines:
298
+ if line_name.casefold() == folded:
299
+ # replace the first line of the field with the new lines,
300
+ # drop the others
301
+ if not inserted:
302
+ new_lines.extend((name, value_) for value_ in values)
303
+ inserted = True
304
+ else:
305
+ new_lines.append((line_name, line_value))
306
+ if not inserted:
307
+ new_lines.extend((name, value_) for value_ in values)
308
+ self._lines = new_lines
309
+
310
+ # narrower than the MutableMapping contract on purpose: update() accepts
311
+ # the same input forms as the constructor (e.g. a raw header block) and
312
+ # takes no **kwargs — header names (e.g. "Content-Type") aren't Python
313
+ # identifiers
314
+ def update( # type: ignore[override] # ty: ignore[invalid-method-override]
315
+ self, headers: Union[HeaderTypes, None] = None
316
+ ) -> None:
317
+ """
318
+ Merge the given headers into this instance: lines of fields that
319
+ already exist are replaced (like ``dict.update``, at the position
320
+ of the field's first line), other fields are appended. Accepts the
321
+ same forms as the constructor (raw header block, mapping, iterable
322
+ of tuples, Headers instance).
323
+
324
+ :param headers: the headers to merge in
325
+ """
326
+ if headers is None:
327
+ return
328
+ other = headers if isinstance(headers, Headers) else Headers(headers)
329
+ for name in other:
330
+ self.set(name, other.get_all(name))
331
+
332
+ def clear(self) -> list[tuple[str, str]]: # type: ignore[override] # ty: ignore[invalid-method-override]
333
+ """
334
+ Remove all fields, returns the removed lines (unlike
335
+ ``MutableMapping.clear`` which returns ``None``).
336
+
337
+ :return: the removed lines as name/value tuples
338
+ """
339
+ old = self._lines
340
+ self._lines = []
341
+ return old
342
+
343
+ def copy(self) -> "Headers":
344
+ """
345
+ :return: a new Headers instance with a copy of the lines
346
+ """
347
+ return Headers(self)
348
+
349
+ def sort(self) -> None:
350
+ """
351
+ Sort the lines in place by their (casefolded) field name. The sort
352
+ is stable: lines of the same field keep their relative order —
353
+ unlike :py:meth:`~action0.url.params.Params.sort`, values are
354
+ never reordered because their order can be significant (e.g.
355
+ ``Set-Cookie``).
356
+ """
357
+ self._lines.sort(key=lambda line: line[0].casefold())
358
+
359
+ def as_str(self, separator: str = "\r\n") -> str:
360
+ r"""
361
+ The wire representation of the header lines, in order, with the
362
+ original casing — secret values are NOT redacted here, unlike in
363
+ ``repr()``.
364
+
365
+ :param separator: the string joining the lines (no trailing one)
366
+ :return: the header block, e.g. ``"Host: example.com\r\nAccept: */*"``
367
+ """
368
+ return separator.join(f"{name}: {value}" for name, value in self._lines)
369
+
370
+ def as_lines(self) -> list[tuple[str, str]]:
371
+ """
372
+ :return: a copy of the representation: the header lines as
373
+ name/value tuples, in order, with the original casing
374
+ """
375
+ return list(self._lines)
376
+
377
+ def as_dict(self) -> dict[str, list[str]]:
378
+ """
379
+ :return: the fields as a dictionary with the field names as keys
380
+ (in the casing of each field's first line) and the values
381
+ as lists of strings
382
+ """
383
+ result: dict[str, list[str]] = {}
384
+ canonical: dict[str, str] = {}
385
+ for name, value in self._lines:
386
+ key = canonical.setdefault(name.casefold(), name)
387
+ result.setdefault(key, []).append(value)
388
+ return result
389
+
390
+ def singles(self) -> dict[str, str]:
391
+ """
392
+ For those who are really sure that each field has only one line
393
+ and do not want to bother with the lists for the values, this
394
+ method will return only the last value for each field.
395
+
396
+ WARNING: be aware, if the field has multiple lines, only one of
397
+ those will be returned for the name!
398
+
399
+ :return: a dictionary with a single value for each field name
400
+ """
401
+ return {name: values[-1] for name, values in self.as_dict().items()}
402
+
403
+ def _folded(self) -> dict[str, list[str]]:
404
+ """
405
+ :return: the fields keyed by casefolded name for order- and
406
+ casing-insensitive comparison
407
+ """
408
+ result: dict[str, list[str]] = {}
409
+ for name, value in self._lines:
410
+ result.setdefault(name.casefold(), []).append(value)
411
+ return result
412
+
413
+ def __eq__(self, other: object) -> bool:
414
+ """
415
+ Headers are equal when they hold the same fields with the same
416
+ values in the same per-field order; the order of different fields
417
+ and the casing of the names don't matter. Plain mappings are
418
+ converted to Headers before comparing.
419
+
420
+ :param other: the Headers instance or mapping to compare with
421
+ :return: whether the headers are equal
422
+ """
423
+ if isinstance(other, Headers):
424
+ return self._folded() == other._folded()
425
+ if isinstance(other, Mapping):
426
+ # cast: the values of an arbitrary mapping are unknown to the
427
+ # type checker; non-string values are coerced like everywhere else
428
+ return self._folded() == Headers(cast("HeaderTypes", other))._folded()
429
+ return NotImplemented
430
+
431
+ def __repr__(self) -> str:
432
+ """
433
+ :return: the header lines in order, with the values of the
434
+ :py:attr:`secret_names` fields redacted as ``***``.
435
+ ``str()`` falls back to this representation, so only
436
+ :py:meth:`as_str` ever renders the secret values.
437
+ """
438
+ rendered = ", ".join(
439
+ f"{name}: {'***' if name.casefold() in self.secret_names else value}"
440
+ for name, value in self._lines
441
+ )
442
+ return f"{self.__class__.__name__}({rendered})"
443
+
444
+
445
+ class Header(StrEnum):
446
+ """
447
+ The known HTTP header field names as string constants.
448
+
449
+ The members are the field names from the `IANA HTTP field name registry
450
+ <https://www.iana.org/assignments/http-fields/>`_ — all ``permanent``,
451
+ ``deprecated`` and ``provisional`` registrations as of 2026-08-07
452
+ (``obsoleted`` ones are left out) — plus a handful of widely used
453
+ de-facto standard ``X-…`` names that were never registered.
454
+
455
+ Being a :py:class:`enum.StrEnum`, every member *is* the header name
456
+ string, so it can be used wherever a plain :py:class:`str` is expected:
457
+
458
+ >>> from action0.req import Header
459
+ >>> print(Header.CONTENT_TYPE)
460
+ Content-Type
461
+ >>> Header.CONTENT_TYPE == "Content-Type"
462
+ True
463
+ >>> Header("ETag") is Header.ETAG
464
+ True
465
+
466
+ ``==`` on the enum is exact, case-sensitive string equality —
467
+ case-insensitive header handling is the job of the header mapping, not
468
+ of these constants.
469
+ """
470
+
471
+ # permanent IANA registrations
472
+ ACCEPT = "Accept"
473
+ ACCEPT_ADDITIONS = "Accept-Additions"
474
+ ACCEPT_CH = "Accept-CH"
475
+ ACCEPT_DATETIME = "Accept-Datetime"
476
+ ACCEPT_ENCODING = "Accept-Encoding"
477
+ ACCEPT_FEATURES = "Accept-Features"
478
+ ACCEPT_LANGUAGE = "Accept-Language"
479
+ ACCEPT_PATCH = "Accept-Patch"
480
+ ACCEPT_POST = "Accept-Post"
481
+ ACCEPT_QUERY = "Accept-Query"
482
+ ACCEPT_RANGES = "Accept-Ranges"
483
+ ACCEPT_SIGNATURE = "Accept-Signature"
484
+ ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials"
485
+ ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers"
486
+ ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods"
487
+ ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"
488
+ ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers"
489
+ ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age"
490
+ ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers"
491
+ ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method"
492
+ AGE = "Age"
493
+ ALLOW = "Allow"
494
+ ALPN = "ALPN"
495
+ ALTERNATES = "Alternates"
496
+ ALT_SVC = "Alt-Svc"
497
+ ALT_USED = "Alt-Used"
498
+ APPLY_TO_REDIRECT_REF = "Apply-To-Redirect-Ref"
499
+ AUTHENTICATION_CONTROL = "Authentication-Control"
500
+ AUTHENTICATION_INFO = "Authentication-Info"
501
+ AUTHORIZATION = "Authorization"
502
+ AVAILABLE_DICTIONARY = "Available-Dictionary"
503
+ A_IM = "A-IM"
504
+ CACHE_CONTROL = "Cache-Control"
505
+ CACHE_GROUPS = "Cache-Groups"
506
+ CACHE_GROUP_INVALIDATION = "Cache-Group-Invalidation"
507
+ CACHE_STATUS = "Cache-Status"
508
+ CALDAV_TIMEZONES = "CalDAV-Timezones"
509
+ CAL_MANAGED_ID = "Cal-Managed-ID"
510
+ CAPSULE_PROTOCOL = "Capsule-Protocol"
511
+ CDN_CACHE_CONTROL = "CDN-Cache-Control"
512
+ CDN_LOOP = "CDN-Loop"
513
+ CERT_NOT_AFTER = "Cert-Not-After"
514
+ CERT_NOT_BEFORE = "Cert-Not-Before"
515
+ CLEAR_SITE_DATA = "Clear-Site-Data"
516
+ CLIENT_CERT = "Client-Cert"
517
+ CLIENT_CERT_CHAIN = "Client-Cert-Chain"
518
+ CLOSE = "Close"
519
+ CONCEALED_AUTH_EXPORT = "Concealed-Auth-Export"
520
+ CONNECTION = "Connection"
521
+ CONTENT_DIGEST = "Content-Digest"
522
+ CONTENT_DISPOSITION = "Content-Disposition"
523
+ CONTENT_ENCODING = "Content-Encoding"
524
+ CONTENT_LANGUAGE = "Content-Language"
525
+ CONTENT_LENGTH = "Content-Length"
526
+ CONTENT_LOCATION = "Content-Location"
527
+ CONTENT_RANGE = "Content-Range"
528
+ CONTENT_SECURITY_POLICY = "Content-Security-Policy"
529
+ CONTENT_SECURITY_POLICY_REPORT_ONLY = "Content-Security-Policy-Report-Only"
530
+ CONTENT_TYPE = "Content-Type"
531
+ COOKIE = "Cookie"
532
+ CROSS_ORIGIN_EMBEDDER_POLICY = "Cross-Origin-Embedder-Policy"
533
+ CROSS_ORIGIN_EMBEDDER_POLICY_REPORT_ONLY = "Cross-Origin-Embedder-Policy-Report-Only"
534
+ CROSS_ORIGIN_OPENER_POLICY = "Cross-Origin-Opener-Policy"
535
+ CROSS_ORIGIN_OPENER_POLICY_REPORT_ONLY = "Cross-Origin-Opener-Policy-Report-Only"
536
+ CROSS_ORIGIN_RESOURCE_POLICY = "Cross-Origin-Resource-Policy"
537
+ DASL = "DASL"
538
+ DATE = "Date"
539
+ DAV = "DAV"
540
+ DELTA_BASE = "Delta-Base"
541
+ DEPRECATION = "Deprecation"
542
+ DEPTH = "Depth"
543
+ DESTINATION = "Destination"
544
+ DETACHED_JWS = "Detached-JWS"
545
+ DICTIONARY_ID = "Dictionary-ID"
546
+ DPOP = "DPoP"
547
+ DPOP_NONCE = "DPoP-Nonce"
548
+ EARLY_DATA = "Early-Data"
549
+ ETAG = "ETag"
550
+ EXPECT = "Expect"
551
+ EXPIRES = "Expires"
552
+ FORWARDED = "Forwarded"
553
+ FROM = "From"
554
+ HOBAREG = "Hobareg"
555
+ HOST = "Host"
556
+ IF = "If"
557
+ IF_MATCH = "If-Match"
558
+ IF_MODIFIED_SINCE = "If-Modified-Since"
559
+ IF_NONE_MATCH = "If-None-Match"
560
+ IF_RANGE = "If-Range"
561
+ IF_SCHEDULE_TAG_MATCH = "If-Schedule-Tag-Match"
562
+ IF_UNMODIFIED_SINCE = "If-Unmodified-Since"
563
+ IM = "IM"
564
+ INCLUDE_REFERRED_TOKEN_BINDING_ID = "Include-Referred-Token-Binding-ID"
565
+ INCREMENTAL = "Incremental"
566
+ KEEP_ALIVE = "Keep-Alive"
567
+ LABEL = "Label"
568
+ LAST_EVENT_ID = "Last-Event-ID"
569
+ LAST_MODIFIED = "Last-Modified"
570
+ LINK = "Link"
571
+ LINK_TEMPLATE = "Link-Template"
572
+ LOCATION = "Location"
573
+ LOCK_TOKEN = "Lock-Token"
574
+ MAX_FORWARDS = "Max-Forwards"
575
+ MEMENTO_DATETIME = "Memento-Datetime"
576
+ METER = "Meter"
577
+ MIME_VERSION = "MIME-Version"
578
+ NEGOTIATE = "Negotiate"
579
+ NEL = "NEL"
580
+ ODATA_ENTITYID = "OData-EntityId"
581
+ ODATA_ISOLATION = "OData-Isolation"
582
+ ODATA_MAXVERSION = "OData-MaxVersion"
583
+ ODATA_VERSION = "OData-Version"
584
+ OPTIONAL_WWW_AUTHENTICATE = "Optional-WWW-Authenticate"
585
+ ORDERING_TYPE = "Ordering-Type"
586
+ ORIGIN = "Origin"
587
+ ORIGIN_AGENT_CLUSTER = "Origin-Agent-Cluster"
588
+ OSCORE = "OSCORE"
589
+ OSLC_CORE_VERSION = "OSLC-Core-Version"
590
+ OVERWRITE = "Overwrite"
591
+ PING_FROM = "Ping-From"
592
+ PING_TO = "Ping-To"
593
+ POSITION = "Position"
594
+ PREFER = "Prefer"
595
+ PREFERENCE_APPLIED = "Preference-Applied"
596
+ PRIORITY = "Priority"
597
+ PROXY_AUTHENTICATE = "Proxy-Authenticate"
598
+ PROXY_AUTHENTICATION_INFO = "Proxy-Authentication-Info"
599
+ PROXY_AUTHORIZATION = "Proxy-Authorization"
600
+ PROXY_STATUS = "Proxy-Status"
601
+ PUBLIC_KEY_PINS = "Public-Key-Pins"
602
+ PUBLIC_KEY_PINS_REPORT_ONLY = "Public-Key-Pins-Report-Only"
603
+ RANGE = "Range"
604
+ REDIRECT_REF = "Redirect-Ref"
605
+ REFERER = "Referer"
606
+ REFERRER_POLICY = "Referrer-Policy"
607
+ REFRESH = "Refresh"
608
+ REPLAY_NONCE = "Replay-Nonce"
609
+ REPR_DIGEST = "Repr-Digest"
610
+ RETRY_AFTER = "Retry-After"
611
+ SCHEDULE_REPLY = "Schedule-Reply"
612
+ SCHEDULE_TAG = "Schedule-Tag"
613
+ SEC_FETCH_DEST = "Sec-Fetch-Dest"
614
+ SEC_FETCH_MODE = "Sec-Fetch-Mode"
615
+ SEC_FETCH_SITE = "Sec-Fetch-Site"
616
+ SEC_FETCH_USER = "Sec-Fetch-User"
617
+ SEC_PURPOSE = "Sec-Purpose"
618
+ SEC_TOKEN_BINDING = "Sec-Token-Binding"
619
+ SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept"
620
+ SEC_WEBSOCKET_EXTENSIONS = "Sec-WebSocket-Extensions"
621
+ SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key"
622
+ SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol"
623
+ SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version"
624
+ SERVER = "Server"
625
+ SERVER_TIMING = "Server-Timing"
626
+ SET_COOKIE = "Set-Cookie"
627
+ SET_TXN = "Set-Txn"
628
+ SIGNATURE = "Signature"
629
+ SIGNATURE_INPUT = "Signature-Input"
630
+ SLUG = "SLUG"
631
+ SOAPACTION = "SoapAction"
632
+ STATUS_URI = "Status-URI"
633
+ STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security"
634
+ SUNSET = "Sunset"
635
+ TCN = "TCN"
636
+ TE = "TE"
637
+ TIMEOUT = "Timeout"
638
+ TOPIC = "Topic"
639
+ TRACEPARENT = "Traceparent"
640
+ TRACESTATE = "Tracestate"
641
+ TRAILER = "Trailer"
642
+ TRANSFER_ENCODING = "Transfer-Encoding"
643
+ TTL = "TTL"
644
+ UNENCODED_DIGEST = "Unencoded-Digest"
645
+ UPGRADE = "Upgrade"
646
+ URGENCY = "Urgency"
647
+ USER_AGENT = "User-Agent"
648
+ USE_AS_DICTIONARY = "Use-As-Dictionary"
649
+ VARIANT_VARY = "Variant-Vary"
650
+ VARY = "Vary"
651
+ VIA = "Via"
652
+ WANT_CONTENT_DIGEST = "Want-Content-Digest"
653
+ WANT_REPR_DIGEST = "Want-Repr-Digest"
654
+ WANT_UNENCODED_DIGEST = "Want-Unencoded-Digest"
655
+ WWW_AUTHENTICATE = "WWW-Authenticate"
656
+ X_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options"
657
+ X_FRAME_OPTIONS = "X-Frame-Options"
658
+ __ = "*"
659
+
660
+ # deprecated IANA registrations (still seen in the wild)
661
+ ACCEPT_CHARSET = "Accept-Charset"
662
+ CONTENT_ID = "Content-ID"
663
+ C_PEP_INFO = "C-PEP-Info"
664
+ DIFFERENTIAL_ID = "Differential-ID"
665
+ EXPECT_CT = "Expect-CT"
666
+ PRAGMA = "Pragma"
667
+ PROTOCOL_INFO = "Protocol-Info"
668
+ PROTOCOL_QUERY = "Protocol-Query"
669
+
670
+ # provisional IANA registrations
671
+ ACTIVATE_STORAGE_ACCESS = "Activate-Storage-Access"
672
+ AMP_CACHE_TRANSFORM = "AMP-Cache-Transform"
673
+ CMCD_OBJECT = "CMCD-Object"
674
+ CMCD_REQUEST = "CMCD-Request"
675
+ CMCD_SESSION = "CMCD-Session"
676
+ CMCD_STATUS = "CMCD-Status"
677
+ CMSD_DYNAMIC = "CMSD-Dynamic"
678
+ CMSD_STATIC = "CMSD-Static"
679
+ CONFIGURATION_CONTEXT = "Configuration-Context"
680
+ CTA_COMMON_ACCESS_TOKEN = "CTA-Common-Access-Token"
681
+ EDIINT_FEATURES = "EDIINT-Features"
682
+ ISOLATION = "Isolation"
683
+ PERMISSIONS_POLICY = "Permissions-Policy"
684
+ REPEATABILITY_CLIENT_ID = "Repeatability-Client-ID"
685
+ REPEATABILITY_FIRST_SENT = "Repeatability-First-Sent"
686
+ REPEATABILITY_REQUEST_ID = "Repeatability-Request-ID"
687
+ REPEATABILITY_RESULT = "Repeatability-Result"
688
+ REPORTING_ENDPOINTS = "Reporting-Endpoints"
689
+ SEC_FETCH_STORAGE_ACCESS = "Sec-Fetch-Storage-Access"
690
+ SEC_GPC = "Sec-GPC"
691
+ SURROGATE_CAPABILITY = "Surrogate-Capability"
692
+ SURROGATE_CONTROL = "Surrogate-Control"
693
+ TIMING_ALLOW_ORIGIN = "Timing-Allow-Origin"
694
+
695
+ # unregistered de-facto standards
696
+ X_API_KEY = "X-API-Key"
697
+ X_CORRELATION_ID = "X-Correlation-Id"
698
+ X_CSRF_TOKEN = "X-CSRF-Token"
699
+ X_FORWARDED_FOR = "X-Forwarded-For"
700
+ X_FORWARDED_HOST = "X-Forwarded-Host"
701
+ X_FORWARDED_PROTO = "X-Forwarded-Proto"
702
+ X_POWERED_BY = "X-Powered-By"
703
+ X_REAL_IP = "X-Real-IP"
704
+ X_REQUEST_ID = "X-Request-Id"
705
+ X_ROBOTS_TAG = "X-Robots-Tag"