Skip to content

Commit 2a37e9e

Browse files
etrclaude
andcommitted
TASK-069: remove transitional two-arg http_request_impl ctor
The two-arg http_request_impl(MHD_Connection*, unescaper_ptr) overload was preserved during the M3 PIMPL split (TASK-015 / TASK-016) "for source compatibility" with callers not yet ported to the allocator- taking form. The v2 cutover is complete and detail/ headers do not require a deprecation cycle, so the overload comes out now. Changes: - src/httpserver/detail/http_request_impl.hpp: delete the two-arg delegating constructor and its comment block. The default ctor (test-request path) and the canonical three-arg allocator-aware ctor remain. - src/http_request.cpp: migrate the sole live caller (the heap-fallback branch when pick_resource returns the default resource) to pass std::pmr::polymorphic_allocator<>(get_default_ resource()) explicitly. Semantically identical to what the delegating ctor did internally; byte-for-byte heap behaviour is unchanged. - test/unit/http_request_pimpl_test.cpp: add three static_asserts pinning the construction surface: 1. default-constructible (test-request path); 2. canonical three-arg (MHD_Connection*, unescaper_ptr, alloc) remains constructible; 3. negative: !is_constructible from (MHD_Connection*, unescaper_ptr) -- the TASK-069 sentinel. If the two-arg overload ever returns, the build breaks here. Verification: - `make check -j1` (release): 98/98 pass. - `make check -j1` (--enable-debug, -Werror -Wextra): 98/98 pass. - Header-only cross-flag sweep compiles the sentinel TU under each of -UHAVE_BAUTH / -UHAVE_DAUTH / -UHAVE_GNUTLS / -UHAVE_WEBSOCKET cleanly (proves the canonical ctor's #ifdef-conditioned member- init list still works under every flag-off permutation, per the plan's Step B). Pre-existing on feature/v2.0, NOT introduced by this task: - check-doxygen.sh fails with 7 warnings (4 @security + start() refs + stale arguments_accumulator refs) in create_webserver.hpp / hook_context.hpp / webserver_websocket.hpp. None of those files are in this diff; tracked separately for a future cleanup. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2a397a8 commit 2a37e9e

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/http_request.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ http_request::http_request(struct MHD_Connection* underlying_connection, unescap
137137
if (res == std::pmr::get_default_resource()) {
138138
// Heap-fallback: matches v1 lifetime exactly; deleter frees via
139139
// operator delete.
140-
impl_.reset(new detail::http_request_impl(underlying_connection, unescaper));
140+
impl_.reset(new detail::http_request_impl(
141+
underlying_connection, unescaper,
142+
std::pmr::polymorphic_allocator<>(std::pmr::get_default_resource())));
141143
impl_.get_deleter().fn = &detail::delete_impl_heap;
142144
} else {
143145
// Arena-backed: allocate and construct via polymorphic_allocator

src/httpserver/detail/http_request_impl.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ class http_request_impl {
9191
std::pmr::polymorphic_allocator<>{
9292
std::pmr::get_default_resource()}) {}
9393

94-
// Two-arg ctor (TASK-015 surface) is preserved for source compatibility
95-
// with any caller that hasn't been ported to the allocator-taking ctor
96-
// yet -- it forwards to the three-arg form with the default resource.
97-
http_request_impl(MHD_Connection* connection, unescaper_ptr unescaper)
98-
: http_request_impl(connection, unescaper,
99-
std::pmr::polymorphic_allocator<>{
100-
std::pmr::get_default_resource()}) {}
101-
10294
// TASK-016: allocator-aware constructor. The PMR-aware containers in
10395
// this impl propagate `alloc` through their value_types via the
10496
// standard scoped-allocator semantics built into

test/unit/http_request_pimpl_test.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131

3232
// HTTPSERVER_COMPILATION is supplied by test/Makefile.am AM_CPPFLAGS.
3333
#include "httpserver/http_request.hpp"
34+
#include "httpserver/detail/http_request_impl.hpp"
3435

3536
#include <map>
37+
#include <memory_resource>
3638
#include <string>
3739
#include <type_traits>
3840
#include <utility>
@@ -132,4 +134,22 @@ static_assert(std::is_same_v<
132134
httpserver::http::file_info>>&>,
133135
"get_files must return const std::map<...>&");
134136

137+
// TASK-069: pin the http_request_impl construction surface. After v2
138+
// cutover, the only public constructors are the no-arg default
139+
// (test-request path, delegates to the three-arg form) and the
140+
// allocator-aware three-arg form. The transitional two-arg overload
141+
// (MHD_Connection*, unescaper_ptr) is gone. If it ever returns, the
142+
// negative is_constructible assertion below breaks the build.
143+
static_assert(std::is_constructible_v<httpserver::detail::http_request_impl>,
144+
"default http_request_impl() must remain (test-request path)");
145+
static_assert(std::is_constructible_v<
146+
httpserver::detail::http_request_impl,
147+
MHD_Connection*, httpserver::unescaper_ptr,
148+
std::pmr::polymorphic_allocator<>>,
149+
"canonical three-arg http_request_impl(MHD_Connection*, unescaper_ptr, alloc) must exist");
150+
static_assert(!std::is_constructible_v<
151+
httpserver::detail::http_request_impl,
152+
MHD_Connection*, httpserver::unescaper_ptr>,
153+
"TASK-069: transitional two-arg http_request_impl ctor must be removed");
154+
135155
int main() { return 0; }

0 commit comments

Comments
 (0)