Diff for /parser3/src/classes/websocket.C between versions 1.1 and 1.3

version 1.1, 2026/10/16 13:55:16 version 1.3, 2026/10/27 23:05:00
Line 30  DECLARE_CLASS_VAR(websocket, new MWebsoc Line 30  DECLARE_CLASS_VAR(websocket, new MWebsoc
   
 // defines  // defines
   
 const size_t MAX_MESSAGE_SIZE_DEFAULT=10*0x400*0x400;  
 #define MAX_CONTROL_SIZE 125  #define MAX_CONTROL_SIZE 125
 #define MAX_REASON_SIZE (MAX_CONTROL_SIZE-2)  #define MAX_REASON_SIZE (MAX_CONTROL_SIZE-2)
   
Line 54  static WebSocket& get_accepted_websocket Line 53  static WebSocket& get_accepted_websocket
         return result;          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  // 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) {  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);          String::Body body=string.cstr_to_string_body_untaint(r.response.lang, r.connection(false), &r.charsets);
Line 82  static void _accept(Request& r, MethodPa Line 89  static void _accept(Request& r, MethodPa
         fields.put(accept_name_upper, new VString(*new String(accept_key)));          fields.put(accept_name_upper, new VString(*new String(accept_key)));
         r.start(VResponse::WEBSOCKET);          r.start(VResponse::WEBSOCKET);
   
         websocket.start(MAX_MESSAGE_SIZE_DEFAULT);          websocket.start(pa_post_max_size);
 }  }
   
 static void _receive(Request& r, MethodParams& params) {  static void _receive(Request& r, MethodParams& params) {
Line 93  static void _receive(Request& r, MethodP Line 100  static void _receive(Request& r, MethodP
                 throw Exception(PARSER_RUNTIME, 0, "timeout must not be negative");                  throw Exception(PARSER_RUNTIME, 0, "timeout must not be negative");
   
         WebSocket::Message message;          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());                  r.write(*VVoid::get());
                 return;                  return;
         }          }

Removed from v.1.1  
changed lines
  Added in v.1.3


E-mail: