--- parser3/src/include/pa_http.h 2026/10/14 00:32:44 1.38 +++ parser3/src/include/pa_http.h 2026/10/26 19:06:51 1.40 @@ -8,7 +8,7 @@ #ifndef PA_HTTP_H #define PA_HTTP_H -#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.38 2026/10/14 00:32:44 moko Exp $" +#define IDENT_PA_HTTP_H "$Id: pa_http.h,v 1.40 2026/10/26 19:06:51 moko Exp $" #include "pa_vstring.h" #include "pa_vint.h" @@ -108,6 +108,13 @@ public: bool read_header(); size_t read_post(char *, size_t); size_t send_body(const void *, size_t); + + /// bytes received after the request headers, not processed yet + String::C unprocessed(); + /// receives up to size bytes, returns 0 if the connection is closed + size_t receive(char *, size_t); + void set_nodelay(); + void set_send_timeout(int timeout_secs); }; class HTTPD_Server : public PA_Allocated { @@ -119,6 +126,15 @@ public: } static mode; static const char *port; + static int max_connections; // not thread local: never changes; INT_MAX by default + static int connections; // accepted and not finished yet + + static bool too_many_connections(){ return connections>max_connections; } + + /// +1 on accept, -1 by whoever owns the connection at the end: + /// HTTPD_Connection destructor destructor, or the parent reaping the child in PARALLEL mode + static void track_connection(int delta); + static void set_mode(const String&); static SOCKET bind(const char *); };