|  | @@ -17764,17 +17764,16 @@ websocket_client_thread(void *data)
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -struct mg_connection *
 | 
	
		
			
				|  |  | -mg_connect_websocket_client(const char *host,
 | 
	
		
			
				|  |  | -                            int port,
 | 
	
		
			
				|  |  | -                            int use_ssl,
 | 
	
		
			
				|  |  | -                            char *error_buffer,
 | 
	
		
			
				|  |  | -                            size_t error_buffer_size,
 | 
	
		
			
				|  |  | -                            const char *path,
 | 
	
		
			
				|  |  | -                            const char *origin,
 | 
	
		
			
				|  |  | -                            mg_websocket_data_handler data_func,
 | 
	
		
			
				|  |  | -                            mg_websocket_close_handler close_func,
 | 
	
		
			
				|  |  | -                            void *user_data)
 | 
	
		
			
				|  |  | +static struct mg_connection *
 | 
	
		
			
				|  |  | +mg_connect_websocket_client_impl(const struct mg_client_options *client_options,
 | 
	
		
			
				|  |  | +                                 int use_ssl,
 | 
	
		
			
				|  |  | +                                 char *error_buffer,
 | 
	
		
			
				|  |  | +                                 size_t error_buffer_size,
 | 
	
		
			
				|  |  | +                                 const char *path,
 | 
	
		
			
				|  |  | +                                 const char *origin,
 | 
	
		
			
				|  |  | +                                 mg_websocket_data_handler data_func,
 | 
	
		
			
				|  |  | +                                 mg_websocket_close_handler close_func,
 | 
	
		
			
				|  |  | +                                 void *user_data)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |  	struct mg_connection *conn = NULL;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -17783,6 +17782,9 @@ mg_connect_websocket_client(const char *host,
 | 
	
		
			
				|  |  |  	static const char *magic = "x3JJHMbDL1EzLkh9GBhXDw==";
 | 
	
		
			
				|  |  |  	static const char *handshake_req;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	int port = client_options->port;
 | 
	
		
			
				|  |  | +	const char *host = client_options->host;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	if (origin != NULL) {
 | 
	
		
			
				|  |  |  		handshake_req = "GET %s HTTP/1.1\r\n"
 | 
	
		
			
				|  |  |  		                "Host: %s\r\n"
 | 
	
	
		
			
				|  | @@ -17899,8 +17901,7 @@ mg_connect_websocket_client(const char *host,
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  |  	/* Appease "unused parameter" warnings */
 | 
	
		
			
				|  |  | -	(void)host;
 | 
	
		
			
				|  |  | -	(void)port;
 | 
	
		
			
				|  |  | +	(void)client_options;
 | 
	
		
			
				|  |  |  	(void)use_ssl;
 | 
	
		
			
				|  |  |  	(void)error_buffer;
 | 
	
		
			
				|  |  |  	(void)error_buffer_size;
 | 
	
	
		
			
				|  | @@ -17915,6 +17916,61 @@ mg_connect_websocket_client(const char *host,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +struct mg_connection *
 | 
	
		
			
				|  |  | +mg_connect_websocket_client(const char *host,
 | 
	
		
			
				|  |  | +                            int port,
 | 
	
		
			
				|  |  | +                            int use_ssl,
 | 
	
		
			
				|  |  | +                            char *error_buffer,
 | 
	
		
			
				|  |  | +                            size_t error_buffer_size,
 | 
	
		
			
				|  |  | +                            const char *path,
 | 
	
		
			
				|  |  | +                            const char *origin,
 | 
	
		
			
				|  |  | +                            mg_websocket_data_handler data_func,
 | 
	
		
			
				|  |  | +                            mg_websocket_close_handler close_func,
 | 
	
		
			
				|  |  | +                            void *user_data)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	struct mg_client_options client_options;
 | 
	
		
			
				|  |  | +	memset(&client_options, 0, sizeof(client_options));
 | 
	
		
			
				|  |  | +	client_options.host = host;
 | 
	
		
			
				|  |  | +	client_options.port = port;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	return mg_connect_websocket_client_impl(&client_options,
 | 
	
		
			
				|  |  | +	                                        use_ssl,
 | 
	
		
			
				|  |  | +	                                        error_buffer,
 | 
	
		
			
				|  |  | +	                                        error_buffer_size,
 | 
	
		
			
				|  |  | +	                                        path,
 | 
	
		
			
				|  |  | +	                                        origin,
 | 
	
		
			
				|  |  | +	                                        data_func,
 | 
	
		
			
				|  |  | +	                                        close_func,
 | 
	
		
			
				|  |  | +	                                        user_data);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +struct mg_connection *
 | 
	
		
			
				|  |  | +mg_connect_websocket_client_secure(
 | 
	
		
			
				|  |  | +    const struct mg_client_options *client_options,
 | 
	
		
			
				|  |  | +    char *error_buffer,
 | 
	
		
			
				|  |  | +    size_t error_buffer_size,
 | 
	
		
			
				|  |  | +    const char *path,
 | 
	
		
			
				|  |  | +    const char *origin,
 | 
	
		
			
				|  |  | +    mg_websocket_data_handler data_func,
 | 
	
		
			
				|  |  | +    mg_websocket_close_handler close_func,
 | 
	
		
			
				|  |  | +    void *user_data)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	if (!client_options) {
 | 
	
		
			
				|  |  | +		return NULL;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	return mg_connect_websocket_client_impl(client_options,
 | 
	
		
			
				|  |  | +	                                        1,
 | 
	
		
			
				|  |  | +	                                        error_buffer,
 | 
	
		
			
				|  |  | +	                                        error_buffer_size,
 | 
	
		
			
				|  |  | +	                                        path,
 | 
	
		
			
				|  |  | +	                                        origin,
 | 
	
		
			
				|  |  | +	                                        data_func,
 | 
	
		
			
				|  |  | +	                                        close_func,
 | 
	
		
			
				|  |  | +	                                        user_data);
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /* Prepare connection data structure */
 | 
	
		
			
				|  |  |  static void
 | 
	
		
			
				|  |  |  init_connection(struct mg_connection *conn)
 |