Skip to content

gta6rt: offline WinHttpSendRequest with context 0 keeps the option's context - #3874

Open
kotorvr wants to merge 1 commit into
ItsNotRexed:mainfrom
kotorvr:winhttp-send-context
Open

kotorvr wants to merge 1 commit into
ItsNotRexed:mainfrom
kotorvr:winhttp-send-context

Conversation

@kotorvr

@kotorvr kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claim: #3796 (comment) (new RT item, offline WinHTTP)

What. send_request in runtime/shims/winhttp_offline.cpp wrote its dwContext to the request unconditionally. A client that sets its context with WINHTTP_OPTION_CONTEXT_VALUE and then calls WinHttpSendRequest(..., 0) got 0 back from WinHttpQueryOption, and 0 in its REQUEST_ERROR and HANDLE_CLOSING callbacks. Now a context of 0 leaves the stored one alone; a nonzero context still replaces it.

How it was measured. A small probe against the host's winhttp.dll (Windows 11 Home 26200; asynchronous session, request to 127.0.0.1 port 1, nothing leaves the machine): after WinHttpSetOption(request, WINHTTP_OPTION_CONTEXT_VALUE, 0xBBB) and WinHttpSendRequest(request, ..., 0), every callback (RESOLVING_NAME, NAME_RESOLVED, CONNECTING_TO_SERVER, REQUEST_ERROR, HANDLE_CLOSING) carried 0xBBB and WinHttpQueryOption returned 0xBBB.

Effect on the game: unproven. docs/runtime_imports.md says the package's DLLs pass their context through WinHttpSendRequest. This PR only makes the stub match WinHTTP for a client that sets it by option.

Changes

  • runtime/shims/winhttp_offline.cpp: send_request keeps the stored context when it is given 0; the header comment says so.
  • runtime/test/winhttp_offline_test.cpp: a new block of 4 checks. A synchronous session checks WinHttpQueryOption. An asynchronous request with its own callback checks REQUEST_ERROR, WinHttpQueryOption and HANDLE_CLOSING. The block has its own callback and events and does not touch the TEST-721 blocks or their waits.
  • docs/runtime_imports.md: one sentence.

Tests (Windows 11, MSVC 19.4x, Visual Studio CMake 3.31 + Ninja, RelWithDebInfo):

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…context

WinHttpSendRequest assigned its dwContext to the request unconditionally, so a client that set the context with
WINHTTP_OPTION_CONTEXT_VALUE and sent with 0 got 0 back from WinHttpQueryOption and in its REQUEST_ERROR and
HANDLE_CLOSING callbacks. The host's winhttp.dll (Windows 11, asynchronous session, loopback) keeps the option's
value in all three. A nonzero dwContext still replaces it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 86be100 on Windows 11 (26200), MSVC (VS 2022 Build Tools) RelWithDebInfo; the test needs no GPU, but it ran under each GPU selection (RTX 5080 driver 616.92, Radeon gfx1036 driver 26.10.1): ctest -R "^winhttp_offline$" plus 20 direct runs of winhttp_offline_test.exe — pass, with one known flake.

  • 5080 ctest run: 54 check(s), 0 failure(s).
  • Radeon ctest run: 54 check(s), 1 failure(s), the only FAIL being notifications not asked for are not sent, and each handle still closes once. That is one of the three TEST-721 HANDLE_CLOSING checks the description lists as the known flake (test: winhttp_offline waits for every HANDLE_CLOSING before counting (TEST-721) #3542), not one of the four new checks.
  • 20 direct runs after that: 20/20 54 check(s), 0 failure(s).

So the 4 new checks passed in all 22 runs. No negative control run.

AI-assisted.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrated 86be100 and #3682 at 0f83451 privately. All four synthetic Windows combinations passed. A zero send context preserved the inherited or explicitly configured value and a nonzero send replaced either. WinHttpQueryOption, REQUEST_ERROR and HANDLE_CLOSING each reported the expected value in every case.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 86be100f on Windows 11, MSVC 19.44.35228 + Ninja, RelWithDebInfo.

  • winhttp_offline_test.exe -> 54 checks, 0 failures, exit 0.
  • ctest -R winhttp --output-on-failure -> 1/1 passed, 0.02 s.

The new case is present in the pass output ("PASS with the context the request was sent with") and the asynchronous callback cases still report the expected context and a single HANDLE_CLOSING. The change is scoped to dwContext == 0 keeping the option's stored value; a nonzero value still replaces it. No game files.

Note only: main now also changes winhttp_offline.cpp for header/timeout parity (4c52ce27), so this branch will need a rebase before merge; the context behavior itself is independent.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS. runtime/shims/winhttp_offline.cpp:221-226 stores dwContext only when it is nonzero, so 0 preserves WINHTTP_OPTION_CONTEXT_VALUE. MSDN does not define 0's meaning, but Wine does exactly if (context) request->hdr.context = context; (request.c:2528), which corroborates the host probe. The test asserts all three surfaces - WinHttpQueryOption, REQUEST_ERROR, HANDLE_CLOSING (runtime/test/winhttp_offline_test.cpp:225-278) - and nonzero replacement stays covered at :297. docs/runtime_imports.md:239 matches, merge clean.

Minor: no case combines a pre-set option with a nonzero send in one block, so "nonzero replaces" is not contrasted directly.

Approve. AI-assisted review, no game files, no GPU.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 86be100 merged onto main 03b09a0 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 154/155.
  • Failed only in the parallel run: xdxr_build_check (passed when rerun on its own).
  • winhttp_offline: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new in the files this PR changes.

AI-assisted (Claude Code).

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.

6 participants