Skip to content

Commit e9175c1

Browse files
committed
TASK-015: http_request_impl skeleton (PIMPL split, structural only)
Move every backend-coupled member of http_request behind a unique_ptr<detail::http_request_impl>. The public header src/httpserver/http_request.hpp no longer includes <microhttpd.h> or <gnutls/gnutls.h>; the only backend-typed names that remain visible at the public surface are forward-declared (MHD_Connection* in the HTTPSERVER_COMPILATION-gated private ctor, and a narrow typedef forward-decl of gnutls_session_t for the still-public get_tls_session() return type that TASK-019 will remove). Outer keeps: path, method, content, version, content_size_limit, plus the impl_ unique_ptr. Everything else (the live MHD_Connection*, unescaper, file table, parsed-args / cookies / cert caches, the MHD trampolines build_request_*, fetch_user_pass(), populate_all_cert_fields()) lives on http_request_impl. Public methods are one-line forwarders. The dtor is out-of-line in http_request.cpp so unique_ptr<impl> sees the complete impl type. Move ctor/assign remain defaulted and operate on the unique_ptr. A new sentinel test/unit/http_request_pimpl_test.cpp asserts that http_request appears non-copy/non-move-constructible from external scope (private moves), and locks sizeof(http_request) at <= 24 pointer widths. Currently 14 pointers (112 B on LP64). Acceptance criteria all green: - grep -E '#include <(microhttpd|gnutls/gnutls)\.h>' on the public header returns nothing. - All v1 request-side tests pass (basic, file_upload, authentication, http_resource, threaded, nodelay, ws_start_stop, uri_log, etc. -- 27 PASS + 1 XFAIL header_hygiene umbrella, unchanged from baseline; the umbrella sweep is TASK-020). - sizeof(http_request) = 14 * sizeof(void*); asserted in the new sentinel. - noinst_HEADERS lists the impl header so it ships in the source tarball but never installs to $prefix/include. - No test reaches across the boundary into http_request_impl.
1 parent 369c2a8 commit e9175c1

8 files changed

Lines changed: 687 additions & 386 deletions

File tree

specs/tasks/M3-request/TASK-015.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
Move `http_request`'s backend-coupled members (`MHD_Connection*`, raw GnuTLS handle, computed caches) into `detail/http_request_impl.hpp` behind a `std::unique_ptr<http_request_impl>`. No API rename yet.
99

1010
**Action Items:**
11-
- [ ] Create `src/httpserver/detail/http_request_impl.hpp` (gated `HTTPSERVER_COMPILATION` only).
12-
- [ ] Move all backend-coupled state into the impl struct: `MHD_Connection* conn_`, `gnutls_session_t tls_session_`, parsed-args cache, headers cache, etc.
13-
- [ ] Public `http_request.hpp` declares `std::unique_ptr<http_request_impl> impl_;` and forward-declares the impl class.
14-
- [ ] Implement existing public methods as forwarders to `impl_->method()`.
15-
- [ ] Move `<microhttpd.h>`, `<gnutls/gnutls.h>` includes from public `http_request.hpp` into `http_request_impl.hpp` and `http_request.cpp`.
11+
- [x] Create `src/httpserver/detail/http_request_impl.hpp` (gated `HTTPSERVER_COMPILATION` only).
12+
- [x] Move all backend-coupled state into the impl struct: `MHD_Connection* conn_`, `gnutls_session_t tls_session_`, parsed-args cache, headers cache, etc.
13+
- [x] Public `http_request.hpp` declares `std::unique_ptr<http_request_impl> impl_;` and forward-declares the impl class.
14+
- [x] Implement existing public methods as forwarders to `impl_->method()`.
15+
- [x] Move `<microhttpd.h>`, `<gnutls/gnutls.h>` includes from public `http_request.hpp` into `http_request_impl.hpp` and `http_request.cpp`.
1616

1717
**Dependencies:**
1818
- Blocked by: TASK-002, TASK-014
@@ -28,4 +28,4 @@ Move `http_request`'s backend-coupled members (`MHD_Connection*`, raw GnuTLS han
2828
**Related Requirements:** PRD-HDR-REQ-001..004
2929
**Related Decisions:** DR-003b, §4.2
3030

31-
**Status:** Not Started
31+
**Status:** In Progress

specs/tasks/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Nominally: **13 sequential tasks**, each S–XL. Most other tasks parallelize of
9797
| TASK-012 | `http_response` fluent `with_*` setters | M2 | Done | TASK-009 |
9898
| TASK-013 | Remove `*_response` subclasses and dispatch virtuals | M2 | Done | TASK-009, TASK-010, TASK-011, TASK-012 |
9999
| TASK-014 | `webserver_impl` skeleton (PIMPL prep) | M3 | In Progress | TASK-002 |
100-
| TASK-015 | `http_request_impl` skeleton (PIMPL split) | M3 | Not Started | TASK-002, TASK-014 |
100+
| TASK-015 | `http_request_impl` skeleton (PIMPL split) | M3 | In Progress | TASK-002, TASK-014 |
101101
| TASK-016 | Per-connection arena for `http_request_impl` | M3 | Not Started | TASK-014, TASK-015 |
102102
| TASK-017 | `http_request` container getters return `const&` | M3 | Not Started | TASK-015 |
103103
| TASK-018 | `http_request` single-key getters return `string_view`, all const | M3 | Not Started | TASK-015, TASK-016 |

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ libhttpserver_la_SOURCES = string_utilities.cpp webserver.cpp http_utils.cpp fil
2323
# noinst_HEADERS: shipped in the tarball but NEVER installed under $prefix/include.
2424
# Detail headers (httpserver/detail/*.hpp) live here so they cannot leak to
2525
# downstream consumers — the public surface comes in through <httpserver.hpp>.
26-
noinst_HEADERS = httpserver/string_utilities.hpp httpserver/detail/modded_request.hpp httpserver/detail/http_endpoint.hpp httpserver/detail/body.hpp httpserver/detail/webserver_impl.hpp gettext.h
26+
noinst_HEADERS = httpserver/string_utilities.hpp httpserver/detail/modded_request.hpp httpserver/detail/http_endpoint.hpp httpserver/detail/body.hpp httpserver/detail/webserver_impl.hpp httpserver/detail/http_request_impl.hpp gettext.h
2727
nobase_include_HEADERS = httpserver.hpp httpserver/body_kind.hpp httpserver/constants.hpp httpserver/create_webserver.hpp httpserver/webserver.hpp httpserver/http_utils.hpp httpserver/file_info.hpp httpserver/http_request.hpp httpserver/http_response.hpp httpserver/http_resource.hpp httpserver/feature_unavailable.hpp httpserver/iovec_entry.hpp httpserver/http_arg_value.hpp httpserver/http_method.hpp
2828

2929
if HAVE_WEBSOCKET

0 commit comments

Comments
 (0)