feat(libSceHttp): accept equivalent Content-Length lists #18292

Merged
Ondra97 merged 1 commit from upstream-pr/18292 into main 2026-11-13 00:52:36 +00:00
Ondra97 commented 2026-11-11 04:06:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-11-11T04:06:35Z.


What

Add the optional recovery for repeated decimal Content-Length values described in RFC 9110 section 8.6 and RFC 9112 section 6.3. A response such as Content-Length: 42, 42 currently fails the reusable HTTP source's single-number parser, even when every member specifies the same body length.

Parse each comma-separated member with the existing strict unsigned-decimal parser, trim optional spaces/tabs, and require every numeric value to match before reading the body. This also handles leading zeroes. Conflicting lengths, empty members, signs, suffixes and overflowing values fail through the existing request-failure path. Other numeric fields retain their existing parser.

Extend the real loopback HTTP fixture with complete responses, partial range responses and empty responses. The client verifies size, payload bytes, seeking and EOF for six accepted forms in each response mode, and rejects thirteen malformed/conflicting forms in each mode. Existing range validation, representation identity, fallback, framing, redirects and cancellation checks still run.

Tested

Windows 11 Pro 26300, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, ANYPS5_RELINKER_ONLY=OFF, ANYPS5_ENABLE_SPIRV_TOOLS=ON. CPU: AMD Ryzen 9 7900X. RAM: 31.66 GiB usable. GPU: NVIDIA GeForce RTX 4070 Ti SUPER; the selected tests do not exercise it.

Upstream base: bb520eba294d933d5d08e9abb3a6235edac41cdf. Tested head: e8b8026a8d2846b8535ff207b7b13033da43e958.

Before editing production code, the new loopback cases failed on that exact base. Only the three single-value controls opened successfully. All invalid cases were already refused. The staged Windows runtime matched the rebuilt provider in both runs.

Metric Before (base) After (feature)
Equivalent Content-Length cases accepted 3/18 18/18
Invalid Content-Length cases refused 39/39 39/39

The final head rebuilt the full production libraries, relinker and selected executables successfully. All ten selected CTests passed, zero failed or skipped, each below 30 seconds: the reusable HTTP client, HTTP APIs/options/diagnostics/response headers, AvPlayer HTTP source and transport, patched HTTP/AvPlayer module integration, patched-library loading and the public-header audit. The 18/18 accepted and 39/39 refused matrix also passed through the patched-module runner. All 407 patched libraries loaded; the audit checked 407 libraries and 33,863 exports. After the composition check, the exact standalone head was restored, rebuilt and passed the same ten tests.

A local, uncommitted composition with #18248 (3cd55326910d752860725e4aa1b8d8dbd3028adb) and #18270 (57452d7cc5c710e39044369c9d785b24a0be0885) merged cleanly, produced tree acd844c1500828ee6ef93a843ae3d8c0e709f8ae, and passed both client modes, including the 203 representation matrix, empty Content-Range cases and the new length-list matrix. The standalone head was restored afterward. No console or title run was performed; this is host HTTP interoperability, with no title-unblock or performance claim.

Commands from the source checkout, with the supported toolchain on PATH and the local full build in ../b:

cmake --build ../b --target relinker libs guest_http_client_tests guest_http_tests guest_http_options_tests guest_http_dbg_printf_tests guest_http_response_header_tests guest_avplayer_tests avplayer_http_transport_tests patched_libraries_tests --parallel 10
cmake -DDEST_DIR=../b/tests -P cmake/CopyRuntimeFiles.cmake ../b/core/libs/libs/unpatched/libSceHttp.prx
ctest --test-dir ../b -R '^(guest_http(_client|_dbg_printf|_options|_response_header)?|guest_avplayer_http|avplayer_http_(transport|patched_modules)|public_headers|patched_libraries)$' --parallel 4 -V --no-tests=error
python tools/check_conventions.py --base origin/main
python tools/pr_overlap.py --base main --branch codex/feat-http-content-length-lists --repo boykopovar/AnyPS5 --jobs 4
git diff --check origin/main...HEAD

Conventions, whitespace and fixture Python syntax checks passed. The overlap tool checked 2,021 open PRs, compared both related HTTP PRs successfully, and exited 0 with no overlap. Their combined runtime result is above; no ordering dependency was found.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5253623763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18292). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-11-11T04:06:35Z. --- ### What Add the optional recovery for repeated decimal Content-Length values described in [RFC 9110 section 8.6](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6) and [RFC 9112 section 6.3](https://www.rfc-editor.org/rfc/rfc9112.html#section-6.3). A response such as `Content-Length: 42, 42` currently fails the reusable HTTP source's single-number parser, even when every member specifies the same body length. Parse each comma-separated member with the existing strict unsigned-decimal parser, trim optional spaces/tabs, and require every numeric value to match before reading the body. This also handles leading zeroes. Conflicting lengths, empty members, signs, suffixes and overflowing values fail through the existing request-failure path. Other numeric fields retain their existing parser. Extend the real loopback HTTP fixture with complete responses, partial range responses and empty responses. The client verifies size, payload bytes, seeking and EOF for six accepted forms in each response mode, and rejects thirteen malformed/conflicting forms in each mode. Existing range validation, representation identity, fallback, framing, redirects and cancellation checks still run. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 26300, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, `ANYPS5_RELINKER_ONLY=OFF`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`. CPU: AMD Ryzen 9 7900X. RAM: 31.66 GiB usable. GPU: NVIDIA GeForce RTX 4070 Ti SUPER; the selected tests do not exercise it. Upstream base: `bb520eba294d933d5d08e9abb3a6235edac41cdf`. Tested head: `e8b8026a8d2846b8535ff207b7b13033da43e958`. Before editing production code, the new loopback cases failed on that exact base. Only the three single-value controls opened successfully. All invalid cases were already refused. The staged Windows runtime matched the rebuilt provider in both runs. | Metric | Before (base) | After (feature) | | --- | --- | --- | | Equivalent Content-Length cases accepted | 3/18 | 18/18 | | Invalid Content-Length cases refused | 39/39 | 39/39 | The final head rebuilt the full production libraries, relinker and selected executables successfully. All ten selected CTests passed, zero failed or skipped, each below 30 seconds: the reusable HTTP client, HTTP APIs/options/diagnostics/response headers, AvPlayer HTTP source and transport, patched HTTP/AvPlayer module integration, patched-library loading and the public-header audit. The 18/18 accepted and 39/39 refused matrix also passed through the patched-module runner. All 407 patched libraries loaded; the audit checked 407 libraries and 33,863 exports. After the composition check, the exact standalone head was restored, rebuilt and passed the same ten tests. A local, uncommitted composition with #18248 (`3cd55326910d752860725e4aa1b8d8dbd3028adb`) and #18270 (`57452d7cc5c710e39044369c9d785b24a0be0885`) merged cleanly, produced tree `acd844c1500828ee6ef93a843ae3d8c0e709f8ae`, and passed both client modes, including the 203 representation matrix, empty Content-Range cases and the new length-list matrix. The standalone head was restored afterward. No console or title run was performed; this is host HTTP interoperability, with no title-unblock or performance claim. Commands from the source checkout, with the supported toolchain on `PATH` and the local full build in `../b`: ```powershell cmake --build ../b --target relinker libs guest_http_client_tests guest_http_tests guest_http_options_tests guest_http_dbg_printf_tests guest_http_response_header_tests guest_avplayer_tests avplayer_http_transport_tests patched_libraries_tests --parallel 10 cmake -DDEST_DIR=../b/tests -P cmake/CopyRuntimeFiles.cmake ../b/core/libs/libs/unpatched/libSceHttp.prx ctest --test-dir ../b -R '^(guest_http(_client|_dbg_printf|_options|_response_header)?|guest_avplayer_http|avplayer_http_(transport|patched_modules)|public_headers|patched_libraries)$' --parallel 4 -V --no-tests=error python tools/check_conventions.py --base origin/main python tools/pr_overlap.py --base main --branch codex/feat-http-content-length-lists --repo boykopovar/AnyPS5 --jobs 4 git diff --check origin/main...HEAD ``` Conventions, whitespace and fixture Python syntax checks passed. The overlap tool checked 2,021 open PRs, compared both related HTTP PRs successfully, and exited 0 with no overlap. Their combined runtime result is above; no ordering dependency was found. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-11 04:10:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T04:10:38Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against e8b8026a8d:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_http_client_tests built cleanly.
  • CTest (guest_http_client):
    1/1 Test #3069: guest_http_client ................   Passed    1.76 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceHttp/src/Client.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3069: guest_http_client ................***Failed    1.74 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified ContentLength in core/libs/prx/libSceHttp/src/Client.cpp strictly validates comma-delimited tokens using Number() (std::from_chars unsigned base 10), rejecting signs, suffixes, fractions, overflow, and empty elements.
    • Verified string view bounds and loop termination in ContentLength: remove_prefix(comma + 1) is guarded by comma != std::string_view::npos, strictly decreasing view size and preventing buffer overrun or infinite looping.
    • Verified conflict detection: std::optionalstd::uint64_t correctly validates equivalence across all list members (including leading-zero representations and zero-length payloads) and throws HttpFailure on mismatch.
    • Verified error handling in HttpClientState::Fetch: malformed or conflicting Content-Length values throw HttpFailure, which Aps5HttpClient_Open_nid_postfix catches to cleanly return 0 with size -1.
    • Verified comprehensive test matrix in core/libs/tests/GuestHttpClient.cpp and core/libs/tests/AvPlayerHttpServer.py covering 18 valid equivalent cases and 39 invalid/conflicting cases across full, range, and empty response modes.
    • Verified strict compliance with AGENTS.md: zero code comments added, no title-specific logic or magic values, no third-party submodules, and all mechanical CI/convention checks pass.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5853748507 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18292#pullrequestreview-5853748507). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-11T04:10:38Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e8b8026a8d`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_http_client_tests` built cleanly. - **CTest** (`guest_http_client`): ``` 1/1 Test #3069: guest_http_client ................ Passed 1.76 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceHttp/src/Client.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3069: guest_http_client ................***Failed 1.74 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified ContentLength in core/libs/prx/libSceHttp/src/Client.cpp strictly validates comma-delimited tokens using Number() (std::from_chars unsigned base 10), rejecting signs, suffixes, fractions, overflow, and empty elements. - Verified string view bounds and loop termination in ContentLength: remove_prefix(comma + 1) is guarded by comma != std::string_view::npos, strictly decreasing view size and preventing buffer overrun or infinite looping. - Verified conflict detection: std::optional<std::uint64_t> correctly validates equivalence across all list members (including leading-zero representations and zero-length payloads) and throws HttpFailure on mismatch. - Verified error handling in HttpClientState::Fetch: malformed or conflicting Content-Length values throw HttpFailure, which Aps5HttpClient_Open_nid_postfix catches to cleanly return 0 with size -1. - Verified comprehensive test matrix in core/libs/tests/GuestHttpClient.cpp and core/libs/tests/AvPlayerHttpServer.py covering 18 valid equivalent cases and 39 invalid/conflicting cases across full, range, and empty response modes. - Verified strict compliance with AGENTS.md: zero code comments added, no title-specific logic or magic values, no third-party submodules, and all mechanical CI/convention checks pass. - Note: the AI-assisted checkbox can stay. Looks Good To Me
MarcZX10 commented 2026-11-12 19:15:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T19:15:16Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

Static reading only. No build, test or CTest run was done here.

  • Head: e8b8026a8d2846b8535ff207b7b13033da43e958, base main.
  • Read the pinned diff for all three changed files, then the head ranges listed below.
Commands
python3 repo_read.py cat core/libs/prx/libSceHttp/src/Client.cpp 1 90
python3 repo_read.py cat core/libs/prx/libSceHttp/src/Client.cpp 420 470
python3 repo_read.py search "ContentLength" core/libs/prx/libSceHttp/src/Client.cpp
python3 repo_read.py search "void Read(" core/libs/tests/GuestHttpClient.cpp
python3 repo_read.py search "100000" core/libs/tests/GuestHttpClient.cpp
python3 repo_read.py search "import" core/libs/tests/AvPlayerHttpServer.py

Results

Check Result Note
Diff read, 3 of 3 files passed Changed hunks only
Matrix counts, 18 and 39 passed Counted from the test arrays by reading
Windows build and CTest not run Author-reported
Conventions and whitespace checks not run Author-reported

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceHttp/src/Client.cpp:60: ContentLength trims spaces and tabs for every value, so a single value with surrounding whitespace is now accepted too. The description implies this, but no fixture case covers it; the single case at core/libs/tests/AvPlayerHttpServer.py:368 has no whitespace. A case with " \t{n}\t " would pin the behaviour.

Sources

Not verified

  • The Windows build, the ten CTests, the 18/18 and 39/39 runtime results and the composition check are author-reported. Not run here.
  • Full text of the three files was not read. Only the diff hunks and the ranges above were read.
  • Field() in core/libs/prx/libSceHttp/src/Client.cpp (line 102) was not read, so I have not checked how header values are trimmed before ContentLength sees them.
  • The range-mode If-Range assertion in the fixture depends on the client sending If-Range. Not traced.
  • Negative control not run here. The author reports the new cases failed on the base commit before the change.

To get this to a good state

Nothing is required. The whitespace case in the non-blocking finding is optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5880565372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18292#pullrequestreview-5880565372). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T19:15:16Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. **What I ran** Static reading only. No build, test or CTest run was done here. - Head: `e8b8026a8d2846b8535ff207b7b13033da43e958`, base `main`. - Read the pinned diff for all three changed files, then the head ranges listed below. <details> <summary>Commands</summary> ``` python3 repo_read.py cat core/libs/prx/libSceHttp/src/Client.cpp 1 90 python3 repo_read.py cat core/libs/prx/libSceHttp/src/Client.cpp 420 470 python3 repo_read.py search "ContentLength" core/libs/prx/libSceHttp/src/Client.cpp python3 repo_read.py search "void Read(" core/libs/tests/GuestHttpClient.cpp python3 repo_read.py search "100000" core/libs/tests/GuestHttpClient.cpp python3 repo_read.py search "import" core/libs/tests/AvPlayerHttpServer.py ``` </details> **Results** | Check | Result | Note | | --- | --- | --- | | Diff read, 3 of 3 files | passed | Changed hunks only | | Matrix counts, 18 and 39 | passed | Counted from the test arrays by reading | | Windows build and CTest | not run | Author-reported | | Conventions and whitespace checks | not run | Author-reported | **Findings** **Blocking** None. **Non-blocking** - `core/libs/prx/libSceHttp/src/Client.cpp:60`: `ContentLength` trims spaces and tabs for every value, so a single value with surrounding whitespace is now accepted too. The description implies this, but no fixture case covers it; the `single` case at `core/libs/tests/AvPlayerHttpServer.py:368` has no whitespace. A case with `" \t{n}\t "` would pin the behaviour. **Sources** - Parser helpers and call site: https://github.com/boykopovar/AnyPS5/blob/e8b8026a8d2846b8535ff207b7b13033da43e958/core/libs/prx/libSceHttp/src/Client.cpp#L53-L70 and #L459 - Test driver: https://github.com/boykopovar/AnyPS5/blob/e8b8026a8d2846b8535ff207b7b13033da43e958/core/libs/tests/GuestHttpClient.cpp#L304-L338 - RFC 9110 section 8.6 and RFC 9112 section 6.3, as cited in the description. **Not verified** - The Windows build, the ten CTests, the 18/18 and 39/39 runtime results and the composition check are author-reported. Not run here. - Full text of the three files was not read. Only the diff hunks and the ranges above were read. - `Field()` in `core/libs/prx/libSceHttp/src/Client.cpp` (line 102) was not read, so I have not checked how header values are trimmed before `ContentLength` sees them. - The range-mode `If-Range` assertion in the fixture depends on the client sending `If-Range`. Not traced. - Negative control not run here. The author reports the new cases failed on the base commit before the change. **To get this to a good state** Nothing is required. The whitespace case in the non-blocking finding is optional.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18292
No description provided.