mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-28 21:08:28 +00:00
There was no way to refuse a connection before the server read a request from it, or before the TLS handshake on SSLServer. The earliest hook was the pre-routing handler, after the request head had been read. set_accept_handler() takes a callback that gets each accepted socket and returns whether to serve it. Both accept paths, with and without keep-alive parking, go through one function, admit_accepted_socket(), which sets the socket timeouts first, so that a handler reading from the socket cannot block forever. A refused or throwing handler closes the socket; an exception is reported as Error::UserCallbackException. Fix #2700