--- parser3/src/classes/websocket.C 2026/10/16 13:55:16 1.1 +++ parser3/src/classes/websocket.C 2026/10/27 23:05:00 1.3 @@ -15,7 +15,7 @@ #include "pa_charsets.h" #include "pa_websocket.h" -volatile const char * IDENT_WEBSOCKET_C="$Id: websocket.C,v 1.1 2026/10/16 13:55:16 moko Exp $" IDENT_PA_WEBSOCKET_H; +volatile const char * IDENT_WEBSOCKET_C="$Id: websocket.C,v 1.3 2026/10/27 23:05:00 moko Exp $" IDENT_PA_WEBSOCKET_H; // class @@ -30,7 +30,6 @@ DECLARE_CLASS_VAR(websocket, new MWebsoc // defines -const size_t MAX_MESSAGE_SIZE_DEFAULT=10*0x400*0x400; #define MAX_CONTROL_SIZE 125 #define MAX_REASON_SIZE (MAX_CONTROL_SIZE-2) @@ -54,6 +53,14 @@ static WebSocket& get_accepted_websocket return result; } +/// the timer is stopped while waiting for the message (not response time) and then started from scratch +class Temp_disable_response_timeout { + Request& r; +public: + Temp_disable_response_timeout(Request& ar) : r(ar) { SAPI::set_response_timeout(r.sapi_info, 0); } + ~Temp_disable_response_timeout() { SAPI::set_response_timeout(r.sapi_info, r.response.timeout); } +}; + // text goes in UTF-8 and the string is in the source charset, tainted data is untainted as in the response static String::C to_utf8(Request& r, const String& string) { String::Body body=string.cstr_to_string_body_untaint(r.response.lang, r.connection(false), &r.charsets); @@ -82,7 +89,7 @@ static void _accept(Request& r, MethodPa fields.put(accept_name_upper, new VString(*new String(accept_key))); r.start(VResponse::WEBSOCKET); - websocket.start(MAX_MESSAGE_SIZE_DEFAULT); + websocket.start(pa_post_max_size); } static void _receive(Request& r, MethodParams& params) { @@ -93,7 +100,12 @@ static void _receive(Request& r, MethodP throw Exception(PARSER_RUNTIME, 0, "timeout must not be negative"); WebSocket::Message message; - if(!websocket.receive(timeout*1000 < INT_MAX ? (int)(timeout*1000) : INT_MAX, message)) { + bool received; + { + Temp_disable_response_timeout temp(r); + received=websocket.receive(timeout*1000 < INT_MAX ? (int)(timeout*1000) : INT_MAX, message); + } + if(!received) { r.write(*VVoid::get()); return; }