Skip to content
Snippets Groups Projects
Commit a88075a0 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Properly upgrade protocol handler

We need to switch protocol handlers on protocol upgrade
parent 8287f3e9
No related branches found
No related tags found
No related merge requests found
...@@ -614,17 +614,23 @@ sub _server_request_http ...@@ -614,17 +614,23 @@ sub _server_request_http
# Its a websocket upgrade request # Its a websocket upgrade request
} elsif ($protocol eq "HTTP=>WebSocket") { } elsif ($protocol eq "HTTP=>WebSocket") {
# Make sure we have an upgrade path to WebSocket
my ($newHandler) = _parse_http_resource($request,"WebSocket");
if (!defined($newHandler)) {
return httpDisplayFault(HTTP_INTERNAL_SERVER_ERROR,"Internal server error","Cannot upgrade to websocket");
}
# Do the function call now # Do the function call now
my ($res,$ret1,$ret2) = $function->($kernel,$globals,$client_session_id,$request,$conn->{'socket'}); my ($res,$ret1,$ret2) = $function->($kernel,$globals,$client_session_id,$request,$conn->{'socket'});
# If we have a response defined, we rejected the upgrade # If we have a response defined, we rejected the upgrade
if (defined($res)) { if (defined($res)) {
$response = httpDisplayFault($res,$ret1,$ret2); $response = httpDisplayFault($res,$ret1,$ret2);
} else { } else {
# Return our upgrade response # Return our upgrade response
$response = _server_request_http_wsupgrade($request,$module,$action); $response = _server_request_http_wsupgrade($request,$module,$action);
# Upgrade the protocol # Upgrade the protocol & handler
$connections->{$client_session_id}->{'protocol'} = 'WebSocket'; $connections->{$client_session_id}->{'protocol'} = 'WebSocket';
$connections->{$client_session_id}->{'resource'}->{'handler'} = $newHandler;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment