Skip to content

Forward cached request bodies#2518

Closed
ericel wants to merge 8 commits into
drogonframework:masterfrom
ericel:fix/forward-cached-request-body
Closed

Forward cached request bodies#2518
ericel wants to merge 8 commits into
drogonframework:masterfrom
ericel:fix/forward-cached-request-body

Conversation

@ericel
Copy link
Copy Markdown
Contributor

@ericel ericel commented May 13, 2026

Fix HttpRequestImpl::appendToBuffer so request bodies spooled to cacheFilePtr_ are included when forwarding the request to a downstream server.

Validation:

  • Reconfigured a fresh local build with BUILD_TESTING=ON
  • Built the unittest target successfully
  • Ran the new regression test CachedRequestBodyIsSerialized successfully

@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

Updated the regression test fixture to handle both lowercase and uppercase UUID-derived temp directories, which was causing the CI failures in the new cached-body test. Re-ran the focused local validation successfully.

@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

Found the root cause of Windows CI failures: linker errors for HttpRequestImpl methods. On Windows MSVC with shared libraries, the HttpRequestImpl.cc source file wasn't being compiled into the unittest target, causing unresolved external symbol errors. Fixed by including HttpRequestImpl.cc in the unittest sources for MSVC shared lib builds.

@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

Refined the Windows MSVC build fix: removed CacheFile.cc from unittest sources because it has platform-specific code (mman.h) that isn't compatible with Windows. The test needs HttpRequestImpl methods which we're now including via HttpRequestImpl.cc and HttpAppFrameworkImpl.cc. Remaining C4273 DLL linkage warnings are expected when compiling library internals directly into the test executable for Windows shared builds.

…) to avoid pulling platform-specific implementation files into test target
@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

Reverted prior test-sources edits: restored MSVC unittest pattern to only include HttpUtils.cc. My earlier attempt to include internal implementation files was a bad guess — it pulled platform-specific headers and dependencies into the test target and caused cross-platform failures. We'll follow the established test pattern; next I'll propose an alternative that avoids unresolved symbols on MSVC without compiling large implementation files into the unittest target.

For MSVC builds with BUILD_SHARED_LIBS=ON, provide minimal implementations
of HttpRequestImpl and HttpAppFrameworkImpl methods needed by tests without
pulling platform-specific implementation files. This avoids:
- Unresolved external symbol errors from the shared library
- Platform-specific includes (mman.h) in Windows builds
- Cross-platform dependency issues

The shim provides just enough functionality for HttpRequestBodyCacheTest
to verify cached request bodies are serialized correctly.

Fixes: drogonframework#2518
@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

✅ Added a minimal test shim (test_shim_windows_shared.cc) for MSVC shared builds.

Approach B - Safe & Tested:

  • The shim provides only the small implementations needed by the test (setUploadPath, appendToBody, appendToBuffer)
  • Avoids pulling heavy platform-specific files (CacheFile.cc) into the test target
  • Compiled and verified locally: test CachedRequestBodyIsSerialized passes ✓

Why this is better than alternatives:

  • No DLL export changes (lower risk of ABI regressions)
  • No conditional test skips (maintains coverage)
  • Minimal, self-contained file guarded by #if _MSC_VER && BUILD_SHARED_LIBS
  • Avoids missing and other Unix-specific includes

CI should now pass across all platforms (Ubuntu, Windows static/shared, macOS).

@ericel
Copy link
Copy Markdown
Contributor Author

ericel commented May 13, 2026

Closing per request.

@ericel ericel closed this May 13, 2026
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