Skip to content

refactor(http): move test_start_line and its patterns into the http base module (#1519) - #1525

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/1519-http-test-start-line
Oct 9, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/1519-http-test-start-line

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

  • Move: httpv1._test_start_line becomes the public http.test_start_line, listed in http.__all__. HTTP._guess_version now calls it directly; the lazy import from httpv1 is gone.
  • Shared patterns: _RE_METHOD, _RE_VERSION, _RE_STATUS and _HTTP2_PREFACE_HEADER move with it and stay private. httpv1 imports them from http, the direction it already imported in, so there is still one copy of each and no new cycle.
  • Docs: test_start_line is documented on the http page and removed from the httpv1 page. Docstrings that cited the old location are updated, including three in tests/const/test_const_method_value_lookup_908_unit.py. The existing changelog entries are left as they are.
  • Tests: test_http_unit.py now imports the predicate from http. The new test_http_test_start_line_1519_unit.py (6 tests) pins request lines, status lines, the HTTP/2 preface refused, non-HTTP refused, the shared pattern objects and the direct call. All 6 fail on origin/main and pass here.
  • Byte-identical: for every frame in all 23 sample captures (1,616 frames, 241 HTTP layers: 231 HTTP/1.1, 10 HTTP/2), the protochain, HTTP version and canonical to_dict() JSON match origin/main exactly. Both snapshots have sha256 2bb6b450….

Ran one at a time: tests/protocols/application, tests/project, tests/test_docstring_contract.py, tests/test_tier_guard.py, and the edited tests/const module. All green. The Sphinx build reports no warnings from the HTTP pages.

Refs #1519

…ase module (#1519)

- httpv1._test_start_line becomes the public http.test_start_line, listed
  in http.__all__; HTTP._guess_version calls it directly instead of
  importing it lazily from httpv1.
- _RE_METHOD, _RE_VERSION, _RE_STATUS and _HTTP2_PREFACE_HEADER move with
  it, and httpv1 imports them from http, so the predicate and the parser
  keep sharing one copy of each.
- Docs: test_start_line is documented on the http page and dropped from
  the httpv1 page; docstrings and test docstrings that cited the old
  location now cite http.py.
- Tests: the existing predicate tests import it from http, and a new
  module pins its request-line, status-line, HTTP/2-preface and non-HTTP
  answers, the shared patterns, and the direct call.

No behaviour change: HTTP classification and to_dict() of all 1,616 frames
in the 23 sample captures are byte-identical to origin/main.
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 9, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at a063c5896. Cross-reviewed on Sonnet; the author ran Opus.

  • Unchanged code: test_start_line and the four patterns are AST-identical to main, including every regex string. httpv1 now reuses http's pattern objects (is holds).
  • No import cycle: at module level, http.py imports nothing from httpv1 or httpv2.
  • Behaviour: classification and to_dict() are byte-identical on main and the PR across 1,616 frames and 241 HTTP layers. 4,057 edge and fuzzed payloads give identical outputs on both trees. On every one, the predicate's answer matches the parser's: 1,217 accepted, 2,777 refused.
  • Tests and docs:
    • Fail-before: 6 failures.
    • pytest does not collect the library function.
    • The two HTTP doc pages build with the same warning set as main.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Coverage: 90.08% (unit tier, Python 3.14, a063c5896, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18795 843 2356 756 92.08%
pcapkit/corekit 2161 66 700 33 96.26%
pcapkit/dumpkit 242 2 88 2 98.79%
pcapkit/foundation 2665 98 934 42 95.00%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 17086 238 4628 190 97.98%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 431 4 124 4 98.56%
pcapkit/vendor 4409 2342 1006 157 43.25%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 9, 2026
@JarryShaw
JarryShaw merged commit 81efa60 into main Oct 9, 2026
40 of 41 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 9, 2026
@JarryShaw
JarryShaw deleted the refactor/1519-http-test-start-line branch October 9, 2026 23:07
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant