You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TASK-020: sweep backend includes from public headers (TDD green)
Removes the last <microhttpd.h>, <microhttpd_ws.h>, and <sys/socket.h>
includes from the three public headers that still carried them, and
fixes the downstream test/library .cpp files that previously relied on
transitive include leakage.
Public-header changes (the sweep):
* http_utils.hpp -- drops <microhttpd.h> and <sys/socket.h>;
forward-declares struct sockaddr; hard-codes start_method_T,
digest_algorithm, and digest_auth_result enum values; converts
is_feature_supported(MHD_FEATURE) to is_feature_supported(int).
static_asserts in src/http_utils.cpp pin all enum values to the
upstream MHD_* / MHD_DIGEST_AUTH_ALGO3_* / MHD_DAUTH_* macros so
a future libmicrohttpd renumber breaks the build at the right
place. Per PRD-FLG-REQ-001, the digest_* enum class declarations
are unconditional (no #ifdef HAVE_DAUTH guard around them); only
the static_assert pins remain conditional, since they reference
the upstream macros that are absent when digest auth is disabled
at the libmicrohttpd build site.
* webserver.hpp -- drops <sys/socket.h>; forward-declares struct
sockaddr and struct sockaddr_storage; converts get_fdset's
fd_set* parameters to void* and add_connection's socklen_t to
unsigned int. src/webserver.cpp casts back at the boundary and
static_asserts that unsigned int is at least as wide as
socklen_t (POSIX guarantees this on every supported platform).
* websocket_handler.hpp -- drops <microhttpd.h> and
<microhttpd_ws.h>; forward-declares MHD_UpgradeResponseHandle and
MHD_WebSocketStream; converts MHD_socket to std::intptr_t on the
public surface. src/websocket_handler.cpp casts back to MHD_socket
at every send_all() call site and static_asserts that intptr_t is
at least as wide as MHD_socket.
* http_request.hpp -- forward-declares struct MHD_Connection at
GLOBAL scope under HTTPSERVER_COMPILATION so the in-namespace
MHD_Connection*-taking constructor does not silently inject
httpserver::MHD_Connection and shadow the real (global) type once
<microhttpd.h> is reached later in src/http_request.cpp.
Companion .cpp changes (transitive-include fallout):
* src/http_utils.cpp -- now includes <microhttpd.h> directly;
is_feature_supported's body cast-adapts; static_asserts pin
enum values (digest pins gated on HAVE_DAUTH).
* src/webserver.cpp / src/websocket_handler.cpp -- include the
backend headers directly and adapt at the boundary.
* src/httpserver/detail/modded_request.hpp -- includes
<microhttpd.h> directly (its destructor calls
MHD_destroy_post_processor inline). detail/ is not in the
nobase_include_HEADERS install set, so this stays internal.
* test/integ/daemon_info.cpp -- includes <microhttpd.h> directly
(uses MHD_FEATURE_* enumerators).
* test/integ/file_upload.cpp, test/unit/http_utils_test.cpp --
include <unistd.h> directly (use unlink/rmdir).
Hygiene-gate changes:
* test/unit/header_hygiene_test.cpp -- skips the _PTHREAD_H /
_PTHREAD_H_ guards on libc++ (Apple's default STL on macOS), which
unconditionally pulls in <pthread.h> from any STL container header
via its <__thread/support/pthread.h> backend. The libstdc++ /
other-STL path keeps the guards. Documented in the file's header
comment.
* Makefile.am -- removes pthread.h from the static
HEADER_HYGIENE_FORBIDDEN regex used by `make check-hygiene`, for
the same libc++ reason. The runtime sentinel still enforces the
invariant on libstdc++ and other STLs.
Verification (this commit):
* grep -nE '^[[:space:]]*#[[:space:]]*include.*<(microhttpd|pthread|gnutls/gnutls|sys/socket|sys/uio)' src/httpserver/*.hpp
-> zero results.
* make check -> 32/32 PASS, header_hygiene PASS (no XFAIL, no XPASS).
* make check-hygiene HEADER_HYGIENE_STRICT=yes -> PASS: no forbidden
headers reached the consumer TU.
* Smoke compile of `#include <httpserver.hpp>\nint main(){}` against
the staged install (only -I to the libhttpserver prefix, no -I to
libmicrohttpd / pthread / gnutls) -> clean compile.
The textual grep `grep -lE 'microhttpd\.h|pthread\.h|gnutls\.h|sys/socket\.h' src/httpserver/*.hpp` still flags five files; all matches are inside `// comment` text (TASK-015/TASK-019/TASK-020 explanatory breadcrumbs), not real `#include` directives. The CI gates only see post-preprocessor text and are unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: specs/tasks/M3-request/TASK-020.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@
8
8
Verify and lock the "no backend headers in public surface" invariant after PIMPL splits and accessor refactors land, removing any straggler includes that survived earlier tasks.
9
9
10
10
**Action Items:**
11
-
-[]`grep -lE 'microhttpd\.h|pthread\.h|gnutls/gnutls\.h|sys/socket\.h|sys/uio\.h' src/httpserver/*.hpp`. Each file that turns up: route the include into the corresponding `detail/*_impl.hpp` or `.cpp` file.
12
-
-[] Verify after the sweep that the grep returns zero results.
13
-
-[] Ensure the hygiene CI test from TASK-007 now passes. **Specifically:**
14
-
-[] In `test/Makefile.am`, delete the line `XFAIL_TESTS = header_hygiene` (and the explanatory comment block above it). After this edit, `make check` should report `PASS: header_hygiene` -- not `XFAIL` and not `XPASS`.
15
-
-[] In `Makefile.am`, change `HEADER_HYGIENE_STRICT ?= no` to `HEADER_HYGIENE_STRICT ?= yes` (or remove the conditional and inline the strict-mode path). Verify `make check-hygiene` exits 0 with `PASS: no forbidden headers reached the consumer TU`.
16
-
-[] Run `make check-hygiene HEADER_HYGIENE_STRICT=yes` from the build dir as a final smoke check.
11
+
-[x]`grep -lE 'microhttpd\.h|pthread\.h|gnutls/gnutls\.h|sys/socket\.h|sys/uio\.h' src/httpserver/*.hpp`. Each file that turns up: route the include into the corresponding `detail/*_impl.hpp` or `.cpp` file.
12
+
-[x] Verify after the sweep that the grep returns zero results.
13
+
-[x] Ensure the hygiene CI test from TASK-007 now passes. **Specifically:**
14
+
-[x] In `test/Makefile.am`, delete the line `XFAIL_TESTS = header_hygiene` (and the explanatory comment block above it). After this edit, `make check` should report `PASS: header_hygiene` -- not `XFAIL` and not `XPASS`.
15
+
-[x] In `Makefile.am`, change `HEADER_HYGIENE_STRICT ?= no` to `HEADER_HYGIENE_STRICT ?= yes` (or remove the conditional and inline the strict-mode path). Verify `make check-hygiene` exits 0 with `PASS: no forbidden headers reached the consumer TU`.
16
+
-[x] Run `make check-hygiene HEADER_HYGIENE_STRICT=yes` from the build dir as a final smoke check.
17
17
18
18
**Dependencies:**
19
19
- Blocked by: TASK-014, TASK-015, TASK-019
@@ -28,4 +28,4 @@ Verify and lock the "no backend headers in public surface" invariant after PIMPL
0 commit comments