Commit Graph
3 Commits
Author SHA1 Message Date
yhirose bba6042bba Decide the graceful close in close_served() itself
Both callers of close_served() worked out from the same connection
whether to close gracefully, so pass what resume() returned and let the
connection check turn.websocket_upgraded once.

Also wait for the keep-alive timeout in both modes at once, which halves
the test to about a second, and describe include_httplib.cc for what it
now does.
2026-11-25 23:39:27 -05:00
yhirose daf46bd502 Serve connections without parking through KeepAliveConnection
Server::process_and_close_socket() repeated what KeepAliveConnection
already does for keep-alive parking: make the stream, look up the
addresses, run process_server_socket_core(), and close. Make it create
the connection with new_keep_alive_connection() and resume() it once,
with a flag that waits for the next request on the worker through
keep_alive(), as before. The flag is checked first, ahead of the stop
check, since keep_alive() serves a request that is already on the socket
even when the server is stopping.

detail::process_server_socket() and process_server_socket_ssl() are no
longer called by the library, but overrides of process_and_close_socket()
call them. Instantiate them in include_httplib.cc, which only the header
build compiles, so that a change to process_server_socket_core() cannot
break them unnoticed.
2026-11-25 22:56:54 -05:00
Joel Rosdahl 887074efd2 Add test of httplib.h split into .h + .cc (#1015)
In order to test the split version (.h + .cc via split.py):

- Added a test_split program in the test directory whose main purpose is
  to verify that it works to compile and link the test case code against
  the split httplib.h version.
- Moved types needed for test cases to the “header part” of httplib.h.
  Also added forward declarations of functions needed by test cases.
- Added an include_httplib.cc file which is linked together with test.cc
  to verify that inline keywords have not been forgotten.

The changes to httplib.h just move code around (or add forward
declarations), with one exception: detail::split and
detail::process_client_socket have been converted to non-template
functions (taking an std::function instead of using a type parameter for
the function) and forward-declared instead. This avoids having to move
the templates to the “header part”.
2021-07-31 09:53:30 -04:00