Repository navigation
Conversation
…ts children make_handle copied the parent's status callback and notification mask to a new handle and left its context at 0. The host's winhttp.dll also passes WINHTTP_OPTION_CONTEXT_VALUE on: a connection and a request start with the context their parent has when they are made, WinHttpQueryOption returns it and their HANDLE_CREATED and HANDLE_CLOSING callbacks carry it. A context set on the handle itself, or given to WinHttpSendRequest, still replaces it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
eventsisstatic, so it persists for the lifetime of the process and won’t reset if this block… · New This block relies on several magic constants (7/9/11/0x51) and repeats the sentinel~DWORD_PTR{0}… · New This block relies on several magic constants (7/9/11/0x51) and repeats the sentinel~DWORD_PTR{0}… · New This block relies on several magic constants (7/9/11/0x51) and repeats the sentinel~DWORD_PTR{0}… · New This block relies on several magic constants (7/9/11/0x51) and repeats the sentinel~DWORD_PTR{0}… · New This block relies on several magic constants (7/9/11/0x51) and repeats the sentinel~DWORD_PTR{0}… · New
What changed in this PR
Aligns the offline WinHTTP shim with host winhttp.dll behavior by inheriting WINHTTP_OPTION_CONTEXT_VALUE from parent handles at creation time, and adds a regression test to verify correct inheritance and callback context propagation.
Changes:
- Copy parent handle
contextinto newly created child handles inmake_handle. - Add a new test block validating context inheritance semantics and callback
HANDLE_CREATED/HANDLE_CLOSINGcontext values. - Update runtime imports documentation to reflect the inherited context behavior.
| File | Description |
|---|---|
| runtime/shims/winhttp_offline.cpp | Makes child handles inherit the parent’s context value at creation time. |
| runtime/test/winhttp_offline_test.cpp | Adds coverage for context inheritance and callback context behavior. |
| docs/runtime_imports.md | Documents that context is inherited from the parent at child creation time. |
Review effort: Lite
| DWORD status; | ||
| DWORD_PTR context; | ||
| }; | ||
| static std::vector<Event> events; // a synchronous session: every callback runs on this thread |
There was a problem hiding this comment.
Done in b1d2a06. The block calls events.clear() before it records. The list stays static because the callback is a lambda without captures and must reach it. This is a test-only change. winhttp_offline_test: 49 checks, 0 failures, six runs.
AI-assisted reply.
| DWORD_PTR value = ~DWORD_PTR{0}; | ||
| DWORD size = sizeof(value); | ||
| return query_option(handle, WINHTTP_OPTION_CONTEXT_VALUE, &value, &size) ? value : ~DWORD_PTR{0}; |
There was a problem hiding this comment.
Done in b1d2a06. The block now has kSessionContext (7), kRequestContext (9), kLaterSessionContext (11), kSendContext (0x51) and kNoContext (~DWORD_PTR{0}). The values and the checks are the same. winhttp_offline_test: 49 checks, 0 failures, six runs.
AI-assisted reply.
| const auto context_at = [&](HINTERNET handle, DWORD status) -> DWORD_PTR { | ||
| for (const Event& e : events) | ||
| if (e.handle == handle && e.status == status) return e.context; | ||
| return ~DWORD_PTR{0}; |
There was a problem hiding this comment.
Done in b1d2a06: this line uses the named constants now. The reply on line 295 gives the names and the test result. AI-assisted reply.
|
|
||
| const HINTERNET session = open(L"test", WINHTTP_ACCESS_TYPE_NO_PROXY, nullptr, nullptr, 0); | ||
| set_callback(session, record, WINHTTP_CALLBACK_FLAG_HANDLES, 0); | ||
| check(set_context(session, 7), "WINHTTP_OPTION_CONTEXT_VALUE can be set on a session"); |
There was a problem hiding this comment.
Done in b1d2a06: this line uses the named constants now. The reply on line 295 gives the names and the test result. AI-assisted reply.
| send(sent, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0x51); | ||
| check(context_of(sent) == 0x51, "the context WinHttpSendRequest is given replaces the inherited one"); |
There was a problem hiding this comment.
Done in b1d2a06: this line uses the named constants now. The reply on line 295 gives the names and the test result. AI-assisted reply.
| const auto set_context = [&](HINTERNET handle, DWORD_PTR value) { | ||
| return set_option(handle, WINHTTP_OPTION_CONTEXT_VALUE, &value, sizeof(value)) != FALSE; | ||
| }; | ||
| const auto context_at = [&](HINTERNET handle, DWORD status) -> DWORD_PTR { | ||
| for (const Event& e : events) | ||
| if (e.handle == handle && e.status == status) return e.context; | ||
| return ~DWORD_PTR{0}; | ||
| }; | ||
|
|
||
| const HINTERNET session = open(L"test", WINHTTP_ACCESS_TYPE_NO_PROXY, nullptr, nullptr, 0); | ||
| set_callback(session, record, WINHTTP_CALLBACK_FLAG_HANDLES, 0); | ||
| check(set_context(session, 7), "WINHTTP_OPTION_CONTEXT_VALUE can be set on a session"); | ||
| const HINTERNET connection = connect(session, L"127.0.0.1", 1, 0); | ||
| const HINTERNET request = open_request(connection, L"GET", L"/", nullptr, WINHTTP_NO_REFERER, | ||
| WINHTTP_DEFAULT_ACCEPT_TYPES, 0); | ||
| check(context_of(connection) == 7 && context_of(request) == 7, | ||
| "a connection and a request start with the session's context"); | ||
| check(context_at(connection, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED) == 7 && | ||
| context_at(request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED) == 7, | ||
| "and their HANDLE_CREATED callbacks carry it"); | ||
|
|
||
| check(set_context(request, 9) && context_of(request) == 9 && context_of(connection) == 7, | ||
| "a context set on the request replaces the inherited one for that request only"); | ||
| check(set_context(session, 11) && context_of(connection) == 7 && context_of(request) == 9, | ||
| "a context set on the session later does not change handles that exist"); | ||
| const HINTERNET late = connect(session, L"127.0.0.1", 1, 0); | ||
| check(context_of(late) == 11, "a connection made after that starts with the new one"); | ||
|
|
||
| const HINTERNET sent = open_request(connection, L"GET", L"/", nullptr, WINHTTP_NO_REFERER, | ||
| WINHTTP_DEFAULT_ACCEPT_TYPES, 0); | ||
| check(context_of(sent) == 7, "a request starts with its connection's context, not the session's"); | ||
| send(sent, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, 0, 0x51); | ||
| check(context_of(sent) == 0x51, "the context WinHttpSendRequest is given replaces the inherited one"); | ||
|
|
||
| close(sent); | ||
| close(request); | ||
| close(late); | ||
| close(connection); | ||
| close(session); | ||
| check(context_at(sent, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING) == 0x51 && | ||
| context_at(request, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING) == 9 && | ||
| context_at(late, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING) == 11 && | ||
| context_at(connection, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING) == 7, |
There was a problem hiding this comment.
Done in b1d2a06: this line uses the named constants now. The reply on line 295 gives the names and the test result. AI-assisted reply.
|
Tested
AI-assisted (Claude Code). |
|
Tested 0f83451 on Windows 11, MSVC 19.42 (VS 2022 Build Tools), Windows SDK 10.0.28000.0, NVIDIA RTX 3080 Ti, driver 616.56: pass
The host measurements in the description, repeated independently against this machine's
Every row agrees with what the new test asserts of the stub. I did not repeat the callback rows ( No blocker found. AI-assisted (Claude Code); no game files, and nothing was resolved, connected or sent. |
kacper-serewis
left a comment
There was a problem hiding this comment.
At 0f83451 all 49 synthetic Windows x64 checks passed. Creation copied the immediate parent's context, later mutations applied to future children, request overrides stayed local, and create/close callbacks reported inherited/final values respectively. Offline shim only. AI-assisted.
|
Tested 0f83451 on Windows 11 Home 26200, MSVC 19.44 (VS 2022), Ninja, RelWithDebInfo (the machine has an RTX 4090 on 621.14, which this CPU-side test does not use): pass. The branch is on
About the second row: TEST-721's intermittent failure is on I did not compare against the host's |
|
Tested Host check: the callback rows, an asynchronous session, two more cases. I wrote a small C++ program against the system
Loop: 30 runs of AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude). No game files. |
|
Tested 0f83451 (merged onto main f847748) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: pass
AI-assisted (Claude). |
…t of the inheritance block Test only, no change of behaviour: the contexts 7, 9, 11 and 0x51 and the "no value" sentinel get constexpr names, and the static event list is cleared before the block records into it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Summary of the review fixes. The new head is b1d2a06. The change is in the test only.
Tests on Windows 11, MSVC 14.51, Windows SDK 10.0.26100.8249, CMake 4.4.3 with Ninja, RelWithDebInfo:
AI-assisted (Claude Code). |


Claim: #3574 (comment) (a new RT item, no ID yet)
What and why
make_handleinruntime/shims/winhttp_offline.cppcopies the parent's status callback and notification mask to a new handle and leaves its context at 0. The host'swinhttp.dllpassesWINHTTP_OPTION_CONTEXT_VALUEon as well. This copies the parent's context in the same place: one line, under the parent's mutex that is already held there.The stub stays what it is: nothing is resolved, connected or sent.
What this does not show: that the game depends on it.
docs/runtime_imports.mdsays the package's DLLs give the context toWinHttpSendRequest, which already worked and is unchanged. This makes the stub answer as the host does for code that sets the context on the session or the connection instead.Measured on the host
With the host's
winhttp.dll, an asynchronous session, a loopback address and no request sent (handles are only created, queried and closed):WinHttpQueryOptionon a new connection and a new requestHANDLE_CREATEDfor the connection and the requestHANDLE_CLOSINGSo the value is the parent's at the moment the child is made, and it does not follow a later change.
Reproduction (no game files)
The new block in
runtime/test/winhttp_offline_test.cppgoes through those steps against the stub, on a synchronous session so every callback runs on the test's thread. Onmainf847748:With the fix:
49 check(s), 0 failure(s). The block also checks that the context given toWinHttpSendRequestreplaces the inherited one.Tests run
Windows 11, Visual Studio 18 (MSVC 14.51), Windows SDK 10.0.26100.8249, CMake 4.4.3 + Ninja, RelWithDebInfo, Vulkan headers from
-DLEONIDA_VULKAN_HEADERS_FETCH=ON; no glslangValidator, llvm-mc or SDL3, so the tests that need them were not built.winhttp_offline_test: 49 checks, 0 failures, six runs in a row. (The known intermittent failure of this test onmain, TEST-721, is in the asynchronous blocks and did not show up in these runs; this change does not touch them.)ctest -C RelWithDebInfo --output-on-failure: 122 tests, 120 passed, 2 failed (d3d12_present,xbox_present), 8 skipped, 1 disabled. Those two fail on this machine on unchangedmainas well, on a swapchain-extent check, and vary from run to run; the machine runs a tiling window manager that resizes new windows, which is the likely cause, not confirmed. Neither touches WinHTTP.python -I tests/test_docs_links.py: OK.No GPU is used by the change or its test. The full
ctestrun used an NVIDIA GeForce RTX 4090, driver 32.0.16.2101.Other open pull requests
#3542 (TEST-721) changes
runtime/test/winhttp_offline_test.cppin three other places (afterms_since, and in the two asynchronous blocks). The new block here is a separate one before theWinHttpCrackUrlblock, and the added#include <vector>is at the top, so the two should merge in either order. No open pull request changeswinhttp_offline.cpp.AI-assisted (Claude Code).
🤖 Generated with Claude Code