Repository navigation
Fix Windows and Apple transport and add shared data URL decoding - #39
Open
CedricGuillemet wants to merge 4 commits into
Open
CedricGuillemet wants to merge 4 commits into
CedricGuillemet wants to merge 4 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Invalid POST headers can persist across request reuse, and the loopback fixture can hang during teardown.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Fixes Windows HTTP header and body handling and adds shared, platform-independent data: GET decoding.
Changes:
- Preserves Windows POST bytes and handles optional Content-Type safely.
- Adds data URL decoding with validation, cancellation, and custom resolver overrides.
- Adds regression tests, dependency wiring, and documentation.
| File | Description |
|---|---|
| Tests/UrlRequestErrorReporting.cpp | Adds Windows HTTP and transport-reuse regressions. |
| Tests/SchemeResolver.cpp | Tests cancellation before resolver invocation. |
| Tests/Main.cpp | Initializes WinRT for tests. |
| Tests/DataUrl.cpp | Tests decoding, validation, and lifecycle behavior. |
| Tests/CMakeLists.txt | Includes new tests and custom entry point. |
| Source/UrlRequest_Windows_Shared.h | Fixes Content-Type handling and preserves POST bytes. |
| Source/UrlRequest_Shared.h | Routes shared resolution through cancellation-aware tasks. |
| Source/UrlRequest_Base.h | Integrates built-in data resolution and error handling. |
| Source/DataUrl.h | Implements data URL decoding and MIME validation. |
| README.md | Documents supported behavior and limitations. |
| NOTICE.md | Adds the base-n license notice. |
| Include/UrlLib/UrlLib.h | Documents shared decoding and resolver behavior. |
| CMakeLists.txt | Pins and includes base-n. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 7, 2026
Write byte-array chunks directly to OutputStream instead of converting through NewStringUTF. Preserve embedded NULs, UTF-8, and empty bodies without changing dependencies. Validated unchanged JsRuntimeHost Fetch/XHR regression coverage on Pixel 9a: 331 JavaScript tests pass (3 pending), all 24 native tests pass, and teardown completes without a crash. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 001e7798-8d3b-44be-8a99-5e8c1541297e
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.


Summary
Fix transport problems encountered during Windows NativeDawn testing in BabylonJS/BabylonNative#1781, plus the corresponding Apple POST byte-preservation issue:
ToString(). Responses without that header previously caused an access violation; the header now remains absent.HttpRequestMessage.Headers()and failed before network I/O with WinRT0x8000000E(misused header name). UseHttpBufferContentto preserve request bytes, explicit MIME parameters, and an omitted Content-Type without injecting a charset.NSData, instead of a NUL-terminated UTF-8NSString. Embedded NUL and invalid-UTF-8 bytes are transmitted unchanged.data:GET decoding through the existing shared scheme resolver, rather than consumer-specific image/fetch wrappers or platform HTTP transports.Supported behavior
The bounded data URL contract is documented in README.md: standard forgiving-base64 and byte percent decoding, default/explicit MIME types, ASCII token/quoted MIME parameters, case-insensitive scheme/base64 marker, empty and non-ASCII/binary bodies, query bytes, and fragment exclusion. Invalid URL/base64/MIME input and unsupported methods report explicit status-0 errors with no partial successful response. String responses retain raw bytes without charset transcoding.
Custom
dataresolvers can override the built-in decoder. Shared resolvers now observe cancellation before invocation and retain once-per-open resolution. Existing Windows response semantics are intentionally preserved: successful 2xx body reads normalize to 200; non-success responses retain their status and do not read/publish their body or response headers.Reuse the pinned base-n helper already used by BabylonNative, validating its input before invoking its permissive decoder, and include its license notice. Avoid decoded-body intermediates and full built-in response-URL copies; ordinary base64 reads directly through a string view into final response storage.
This does not implement browser URL canonicalization, permissive MIME recovery, charset conversion, base64url, streaming, CORS, or all Fetch behavior. Linux POST remains unimplemented and outside this change; common POST wire tests explicitly skip on that backend.
Validation
Review follow-up
Related work
Complementary to #35 (HTTP version negotiation) and #38 (Android/Apple response-read failures), with no duplicated production fixes. #38 overlaps the loopback test fixture and README; that fixture should be consolidated when merging both changes.