Is your feature request related to a problem? Please describe.
Case sensitivity of registry lookups is currently decided ad hoc. Four registries override get and one helper case-folds, and until now nobody had checked whether each one's behaviour matches what its source specification actually says.
The ruling that governs it, from #877:
okay, then we've found the verdict. and that's the logic - if RFC states the values are case-insensitive, then our enum should also treat them that way. otherwise, we should treat them case sensitive.
and the follow-up that makes this its own piece of work:
on (2) - we should audit all registries and then decide if case (in)sensitive.
Describe the solution you'd like
Audit every registry under pcapkit/const/ plus the non-registry helper enums — 124 and 27 respectively by the last count — against the RFC or IANA registry its values come from, and record per registry whether the specification makes those values case-insensitive. Then apply the ruling: case-insensitive lookup only where the source says so, case-sensitive everywhere else.
The deliverable is the audit table plus the changes it implies, and the table belongs in docs/source/conventions.rst beside the ruling so the next registry added has something to check itself against.
What is already established, so it need not be re-derived
| class |
behaviour |
verdict |
pcapkit/const/ftp/command.py Command |
value.upper() at :104 |
correct, keep — RFC 959 §4.1: "The command codes are four or fewer alphabetic characters. Upper and lower case alphabetic characters are to be treated identically." |
pcapkit/const/http/method.py Method |
key.upper() at :232-242 |
defect — RFC 9110 §9.1: "The method token is case-sensitive because it might be used as a gateway to object-based systems with case-sensitive method names." Tracked as #896. |
helper TransportProtocol |
case-insensitive, load-bearing: pcapkit/const/reg/apptype/apptype.py:101-102 does key.lower() against __members__, and :2480 calls TransportProtocol.get(proto.lower()) |
open — the maintainer named this as his example of legitimate case-insensitivity, so if nothing backs it the ruling bites two real call sites |
pcapkit/const/pcapng/option_type.py OptionType |
get(key: 'int | str', …) |
open |
pcapkit/const/reg/apptype/apptype.py AppType |
get(cls, key: 'int', …), int-keyed |
open, probably moot |
Also settled: HTTP field names genuinely are case-insensitive (RFC 9110 §5.1), which is a different thing from method tokens and must not be conflated.
Method notes
Fetch RFC text with curl https://www.rfc-editor.org/rfc/rfcNNNN.txt and grep it — a WebFetch of these documents truncates before the relevant sections, which cost two wasted attempts.
Calling Cls(value) on a registry whose _missing_ mints mutates the class, so a probe is not a read: snapshot {m.value for m in Cls} first and use a throwaway process per registry.
Additional context
Depends on #877, whose phase 1 establishes the bare lookup base and records the convention. The base's get is case-sensitive by that ruling, so every case-insensitive registry becomes an explicit, justified override — which is what makes this audit actionable rather than academic.
Is your feature request related to a problem? Please describe.
Case sensitivity of registry lookups is currently decided ad hoc. Four registries override
getand one helper case-folds, and until now nobody had checked whether each one's behaviour matches what its source specification actually says.The ruling that governs it, from #877:
and the follow-up that makes this its own piece of work:
Describe the solution you'd like
Audit every registry under
pcapkit/const/plus the non-registry helper enums — 124 and 27 respectively by the last count — against the RFC or IANA registry its values come from, and record per registry whether the specification makes those values case-insensitive. Then apply the ruling: case-insensitive lookup only where the source says so, case-sensitive everywhere else.The deliverable is the audit table plus the changes it implies, and the table belongs in
docs/source/conventions.rstbeside the ruling so the next registry added has something to check itself against.What is already established, so it need not be re-derived
pcapkit/const/ftp/command.pyCommandvalue.upper()at:104pcapkit/const/http/method.pyMethodkey.upper()at:232-242TransportProtocolpcapkit/const/reg/apptype/apptype.py:101-102doeskey.lower()against__members__, and:2480callsTransportProtocol.get(proto.lower())pcapkit/const/pcapng/option_type.pyOptionTypeget(key: 'int | str', …)pcapkit/const/reg/apptype/apptype.pyAppTypeget(cls, key: 'int', …), int-keyedAlso settled: HTTP field names genuinely are case-insensitive (RFC 9110 §5.1), which is a different thing from method tokens and must not be conflated.
Method notes
Fetch RFC text with
curl https://www.rfc-editor.org/rfc/rfcNNNN.txtand grep it — aWebFetchof these documents truncates before the relevant sections, which cost two wasted attempts.Calling
Cls(value)on a registry whose_missing_mints mutates the class, so a probe is not a read: snapshot{m.value for m in Cls}first and use a throwaway process per registry.Additional context
Depends on #877, whose phase 1 establishes the bare lookup base and records the convention. The base's
getis case-sensitive by that ruling, so every case-insensitive registry becomes an explicit, justified override — which is what makes this audit actionable rather than academic.