Skip to content

fix(windows): send content headers with the request body - #11663

Merged
triniwiz merged 1 commit into
feat/windowsfrom
fix/windows-http-content-headers
Nov 21, 2026
Merged

triniwiz merged 1 commit into
feat/windowsfrom
fix/windows-http-content-headers

Conversation

@triniwiz

Copy link
Copy Markdown
Member

Problem

On Windows, http.request, and so fetch and XMLHttpRequest, sent a string body as text/plain, whatever Content-Type the caller set.

The request headers were appended to HttpRequestMessage.Headers. WinRT refuses content headers there (Content-Type, Content-Encoding and the like belong to HttpContent.Headers), and the try/catch swallowed the failure. HttpStringContent then went out with its default text/plain; charset=UTF-8.

Servers that only parse JSON when it's labelled as JSON saw an empty body. For example, a Colyseus joinOrCreate lost its options: the player got a random name and the default look instead of the ones sent.

Fix

Content headers are held back while the message headers are filled. Once the body is set, they're added to requestMessage.Content.Headers, replacing the content's default. Content-Length is left to WinRT, which sets it from the body.

Testing

Tested on Windows in a WinUI 3 game whose client joins a Colyseus room with { name, look }:

  • Before: the server received no options and picked a random name.
  • After: the player joined with the name and outfit that were sent.

@nx-cloud

nx-cloud Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2dbe6d0

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 16s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-21 23:27:10 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11663
npm i https://pkg.pr.new/@nativescript/vite@11663
npm i https://pkg.pr.new/@nativescript/webpack@11663

commit: 2dbe6d0

Content-Type and the other content headers were appended to the
message's headers, which WinRT refuses for them (the failure was
swallowed), so a string body went out as HttpStringContent's default
text/plain. A server that only parses JSON when it's labelled as JSON
saw an empty body: a Colyseus joinOrCreate lost its options.

Content headers now go on the body's headers once the body is set,
replacing the content's default; Content-Length is left to WinRT.
@triniwiz
triniwiz force-pushed the fix/windows-http-content-headers branch from 8fbebfc to 2dbe6d0 Compare November 21, 2026 23:20
@triniwiz
triniwiz changed the base branch from feat/linux to feat/windows November 21, 2026 23:20
@triniwiz
triniwiz merged commit 1698f3c into feat/windows Nov 21, 2026
7 checks passed
@triniwiz
triniwiz deleted the fix/windows-http-content-headers branch November 21, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant