Repository navigation
fix(const): resolve every three-digit FTP reply and HTTP status code (#1443) - #1444
Merged
Merged
Conversation
…1443) ReturnCode resolved only 100-659 and StatusCode only 100-599, so a reply such as `999 hi` or a status line such as `HTTP/1.1 999 X` raised EnumValueError and could not be parsed. Both wire fields are three digits, so 0-999 now resolve: inside the registry's range as before, outside it to an `Unknown` pseudo-member. ReturnCode derives kind and group from the zero-padded code, and FTP/HTTP make() write the code as three digits, so `099` rebuilds byte for byte. The vendor templates carry the same change.
JarryShaw
force-pushed
the
fix/1443-unassigned-ftp-http-codes
branch
from
October 9, 2026 00:59
cb5c41d to
e4a9c71
Compare
JarryShaw
marked this pull request as ready for review
October 9, 2026 00:59
Contributor
|
Coverage: 89.51% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Verdict: GOOD TO GO at
For the owner: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort) — not runmake testpasses, and a test case covers the change — new module,protocols(non-internet) andconstlegs,tests/projectAdded a changelog entry — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657
fix— corrects a defectCloses #1443
Before:
FTP(b'999 hi\r\n', 8),FTP(b'099 x\r\n', 7),HTTP(b'HTTP/1.1 999 X\r\n\r\n', 20)andReturnCode.get(777)raiseEnumValueError; 440/1000 FTP and 500/1000 HTTP codes fail to parse. After: all 1000 of each parse and rebuild byte-exact viafrom_data; values outside the registry range resolve to anUnknownpseudo-member (not registered), -1 and 1000 still raise.make()now writes the code zero-padded (099, not99).Vendor templates (
pcapkit/vendor/{ftp/return_code,http/status_code}.py) carry the same change; rendering both crawlers offline from today's Wikipedia/IANA snapshots reproduces the committedconst/files byte-identically (and did so onmainbefore the change).Tests:
tests/protocols/application/test_ftp_http_unassigned_code_1443_unit.py— 9 passed / 2017 subtests; with the source reverted, 7 of 9 tests fail (949 subtests).protocols --exclude protocols/internetleg: 1119 tests, 0 failures.tests/project: 419 passed, 1 skipped.Existing test:
tests/const/test_const_enum_lookup.pydropsReturnCodeandStatusCodefromEXPECTED_TO_REJECT_ZERO(#492), which pinned0raising. Both wire fields are three digits, so000now parses to anUnknownpseudo-member.constleg: 502 tests, 0 failures.