Commit d8b055e
Migrate to libmicrohttpd 1.0.0 API with new features (#370)
* Migrate to libmicrohttpd 1.0.0 API with new features
Raise minimum libmicrohttpd requirement to 1.0.0 and migrate all
deprecated APIs to their v3 replacements:
- Basic Auth: MHD_basic_auth_get_username_password3,
MHD_queue_basic_auth_required_response3 with UTF-8 support
- Digest Auth: MHD_digest_auth_check3, MHD_digest_auth_check_digest3,
MHD_queue_auth_required_response3 with SHA-512/256, userhash,
nonce binding, and structured digest_auth_result enum
Add new response types: empty_response, pipe_response, iovec_response.
Add external event loop integration (run, run_wait, get_fdset,
get_timeout, add_connection), daemon management (quiesce, get_listen_fd,
get_active_connections, get_bound_port), and numerous new daemon options
(listen_backlog, address_reuse, tcp_fastopen_queue_size, turbo, etc.).
Add conditional WebSocket support via libmicrohttpd_ws.
Add utility functions: reason_phrase, is_feature_supported, get_mhd_version.
* Update README with all new MHD 1.0 features and options
Document WebSocket support, new response types (empty, iovec, pipe),
external event loop integration, daemon introspection methods, new
server configuration options (turbo, no_listen_socket, suppress_date_header,
etc.), enhanced TLS options, updated digest authentication API with
SHA-256/SHA-512/256 and fine-grained result codes, and new http_utils
utility methods.
* Add examples for new MHD 1.0 features and document them in README
New example files:
- empty_response_example: 204 No Content and HEAD-only responses
- iovec_response_example: scatter-gather response from multiple buffers
- pipe_response_example: streaming response from a pipe fd
- websocket_echo: WebSocket echo server with on_open/on_message/on_close
- daemon_info: daemon introspection (bound port, listen fd, http_utils)
- external_event_loop: driving the server with run_wait() and quiesce()
- turbo_mode: high-performance config with turbo, suppressed date header,
TCP Fast Open, and listen backlog
All examples are added to the Other Examples section of the README with
inline code, test commands, and links to the source files.
* Cleaned-up validation issues
* fix codacy warnings
* Add documentation and example for serving binary data from memory
The existing string_response already supports binary content (std::string
can hold arbitrary bytes), but this was not documented or demonstrated
anywhere. This gap caused users to believe a new response type was needed
(see PR #368).
- Add a note to the README's string_response description clarifying
binary data support
- Add a new "Serving binary data from memory" section with inline example
- Add examples/binary_buffer_response.cpp as a complete, buildable example
that serves a PNG image from an in-memory buffer
- Register the new example in examples/Makefile.am
https://claude.ai/code/session_01S3BvBrSoNvUhpYTyhPYCjJ
* Fix CI: add ChangeLog entry and missing include <utility>
Add ChangeLog entry for the binary buffer example to satisfy the
ChangeLog Check workflow. Add missing #include <utility> for
std::move to fix cpplint warning.
https://claude.ai/code/session_01S3BvBrSoNvUhpYTyhPYCjJ
* Migrate to libmicrohttpd 1.0.0 API with new features
Raise minimum libmicrohttpd requirement to 1.0.0 and migrate all
deprecated APIs to their v3 replacements:
- Basic Auth: MHD_basic_auth_get_username_password3,
MHD_queue_basic_auth_required_response3 with UTF-8 support
- Digest Auth: MHD_digest_auth_check3, MHD_digest_auth_check_digest3,
MHD_queue_auth_required_response3 with SHA-512/256, userhash,
nonce binding, and structured digest_auth_result enum
Add new response types: empty_response, pipe_response, iovec_response.
Add external event loop integration (run, run_wait, get_fdset,
get_timeout, add_connection), daemon management (quiesce, get_listen_fd,
get_active_connections, get_bound_port), and numerous new daemon options
(listen_backlog, address_reuse, tcp_fastopen_queue_size, turbo, etc.).
Add conditional WebSocket support via libmicrohttpd_ws.
Add utility functions: reason_phrase, is_feature_supported, get_mhd_version.
* Fix Codacy CWE-126: replace strlen with std::char_traits::length
Replace strlen(s) with std::char_traits<char>::length(s) in
unescaper_func to silence Codacy static analysis warning about
potential over-read on non-null-terminated strings. The MHD API
guarantees s is null-terminated, but using the C++ equivalent
avoids false positives from C-focused analyzers.
* libmicro to v1.0.3
* libmicrohttpd to 1.0.3 in codeql checks
* Fix CI: cpplint errors, external event loop test, and Windows pipe build
- Add missing #include <utility> and <string> in headers and examples
- Reorder includes in webserver.cpp to satisfy cpplint include order
- Add NOLINT(runtime/int) for curl API's long parameters
- Add EXTERNAL_SELECT start method (MHD_USE_AUTO without internal
threading) for proper external event loop support
- Fix daemon_info test and external_event_loop example to use
EXTERNAL_SELECT instead of INTERNAL_SELECT with run_wait()
- Fix pipe_response_example to compile on Windows (_pipe + <io.h>)
* Fix Windows build for new_response_types test
Test file was missed in d4808b4 which fixed the same pattern in
pipe_response_example.cpp. MinGW64 has _pipe, not pipe.
* Silence cpplint readability/braces on Windows-guarded class
cpplint's brace check gets confused by the #if/#else/#endif inside
pipe_resource::render_GET, matching the existing NOLINT in
examples/pipe_response_example.cpp.
* Fix Windows external_event_loop test: drop no_thread_safety()
On Windows/MSYS2, MHD_start_daemon rejects the combination of
MHD_USE_AUTO (EXTERNAL_SELECT) and MHD_USE_NO_THREAD_SAFETY,
causing daemon_info.exe test #6 to fail with
"Unable to connect daemon to port: 8080". Drop no_thread_safety()
from both the test and the matching example; the default
thread-safe daemon is still drivable from a single thread via
MHD_run_wait.
* Fix Windows port leak in quiesce_does_not_crash test
MHD_quiesce_daemon transfers the listen socket to the caller. On
Windows, MHD sockets are Winsock SOCKETs and POSIX close() from
<unistd.h> does not close them, so the prior version leaked the
socket and left port 8080 bound. The next test in the same binary
(external_event_loop) then failed MHD_start_daemon with
"Unable to connect daemon to port: 8080".
Use closesocket() on Windows and close() elsewhere.
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a752404 commit d8b055e
38 files changed
Lines changed: 2809 additions & 349 deletions
File tree
- examples
- src
- httpserver
- test
- integ
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
3 | 25 | | |
4 | 26 | | |
5 | 27 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | | - | |
158 | | - | |
| 157 | + | |
| 158 | + | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| |||
283 | 290 | | |
284 | 291 | | |
285 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
286 | 301 | | |
287 | 302 | | |
288 | 303 | | |
| |||
341 | 356 | | |
342 | 357 | | |
343 | 358 | | |
| 359 | + | |
344 | 360 | | |
345 | 361 | | |
346 | 362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
36 | 42 | | |
37 | 43 | | |
38 | | - | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments