test(UnitTest): handle early local HTTP requests - #14729
Conversation
03ee5b0 to
903cd28
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #14729 +/- ##
==========================================
+ Coverage 25.47% 33.28% +7.80%
==========================================
Files 769 919 +150
Lines 65912 82944 +17032
Branches 30495 38312 +7817
==========================================
+ Hits 16788 27604 +10816
+ Misses 37285 36616 -669
- Partials 11839 18724 +6885
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Build ResultsPlatform Status
All builds passed. Pre-commit
Pre-commit hooks: 2 passed, 75 failed, 7 skipped. Test Resultslinux-coverage-integration: 41 passed, 0 skipped Code Coverage
Artifact Sizes
Updated: 2026-08-10 05:38:03 UTC • Commit: d970595 • Triggered by: Windows |
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability of the TestFixtures::LocalHttpTestServer test infrastructure by ensuring already-buffered and fragmented HTTP request headers are fully accumulated before a response is sent, and adds a regression unit test covering the early/fragmented request scenario.
Changes:
- Adds
LocalHttpTestServerTestto validate that the server does not respond to an incomplete HTTP request header fragment. - Updates
LocalHttpTestServer::installRawResponderto consume already-buffered bytes and wait for\r\n\r\nbefore responding. - Registers the new unit test in the UnitTestFramework Tests CMake target.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/UnitTestFramework/Tests/LocalHttpTestServerTest.h | Adds a new UnitTest class for LocalHttpTestServer regression coverage. |
| test/UnitTestFramework/Tests/LocalHttpTestServerTest.cc | Implements a regression test that splits an HTTP header across writes and asserts no early response. |
| test/UnitTestFramework/Tests/CMakeLists.txt | Adds the new test sources and registers LocalHttpTestServerTest. |
| test/UnitTestFramework/Fixtures/LocalHttpTestServer.cc | Updates the raw responder to accumulate request data and respond only after the header terminator is received. |
|
Review feedback from a Claude Fable review: Worth changing
Optional
For the record: the core fix is correct and well-tested — the fragmented-header regression test genuinely fails against the old single-shot responder, and the shared-state/lifetime handling ( |
|
Claude Fable review — assessment of the two Copilot inline comments: 1. IPv4/IPv6 bind mismatch in 2. Size bound enforced after |
e7bb8c4 to
67caa46
Compare
|
Thanks. The review points are addressed in
For the size bound, I followed your recommendation: terminal-state latching without adding the budgeted-read branches to this loopback fixture. A standalone Qt 6.4.2 fragmented-header probe passed at the pushed head; QGC CI is running. |
|
All changes look good thanks. Kicking off another final CoPilot review... |
|
@alireza787b Ok, this is good to go now. Can you squash to single commit and then once last CI passes I'll merge. |
Wait for complete request headers in the loopback HTTP fixture, latch oversized requests before disconnecting, and cover fragmented IPv4/IPv6 request delivery.
67caa46 to
d970595
Compare
Description
LocalHttpTestServercould respond to the firstreadyReadnotification even when it contained only part of an HTTP request header. That made camera-free transport tests timing-dependent.The responder now accumulates a bounded request header across notifications and sends exactly one response after
\r\n\r\narrives. Oversized headers latch a terminal state before disconnecting. An immediate read after installing the socket callbacks remains as defensive handling for already-buffered data, but fragmented headers are the regression fixed here.The regression test splits the header across two writes, verifies that the first fragment receives no response, and connects through
server.url()so IPv4 and IPv6 fixture binds follow the same contract.This changes test infrastructure only; application networking is unchanged.
Type of Change
Testing
Local checks on exact head
67caa46a0cdcb6f3cf4a9c232956dd9a074bdc45:git diff --check.Exact-head QGC CI is complete: Linux x64/arm64 release builds, unit and integration tests, ASan/UBSan, coverage thresholds, Windows, macOS, iOS, Android, Docker, custom-plugin, and CodeQL checks passed. Linux evidence: run 30596338957.
Platforms Tested
Flight Stacks Tested
Not applicable; this is a unit-test fixture.
Screenshots
Not applicable; there is no UI change.
Checklist
Related Issues
#14730 carries this as a test-infrastructure prerequisite because its camera-free MJPEG delivery test uses
installRawResponder.By submitting this pull request, I confirm that my contribution is made under the terms of the project's dual license (Apache 2.0 and GPL v3).