Skip to content
Snippets Groups Projects
Commit e708be7f authored by Arne Goedeke's avatar Arne Goedeke
Browse files

Revert "WebSocket: Call either http_cb or ws_cb, not both, at the proper moment."

This reverts commit 7ce9c4ae.
parent 8e590b86
No related branches found
No related tags found
No related merge requests found
......@@ -192,7 +192,7 @@ protected void read_cb(mixed dummy,string s)
request_raw=v[1];
parse_request();
if (parse_variables(0))
if (parse_variables())
finalize();
}
else
......@@ -348,16 +348,13 @@ private void read_cb_chunked( mixed dummy, string data )
call_out(connection_timeout,connection_timeout_delay);
}
protected int parse_variables(int short)
protected int parse_variables()
{
if (query!="")
.http_decode_urlencoded_query(query,variables);
flatten_headers();
if (short)
return 1;
if ( request_headers->expect )
{
if ( lower_case(request_headers->expect) == "100-continue" )
......@@ -434,10 +431,6 @@ protected void parse_post()
}
}
protected int alternatecallback() {
return 0;
}
protected void finalize()
{
my_fd->set_blocking();
......@@ -453,7 +446,6 @@ protected void finalize()
foreach (request_headers->cookie/";";;string cookie)
if (sscanf(String.trim_whites(cookie),"%s=%s",string a,string b)==2)
cookies[a]=b;
if (!alternatecallback())
request_callback(this);
}
}
......
......@@ -585,7 +585,8 @@ class Connection {
class Request(function(array(string), Request:void) cb) {
inherit Protocols.HTTP.Server.Request;
protected int alternatecallback() {
protected void parse_request() {
::parse_request();
if (cb && has_index(request_headers, "sec-websocket-key")) {
string proto = request_headers["sec-websocket-protocol"];
array(string) protocols = proto ? proto / ", " : ({});
......@@ -593,14 +594,16 @@ class Request(function(array(string), Request:void) cb) {
werror("websocket request: %O %O\n", this, protocols);
#endif
cb(protocols, this);
return 1;
}
return 0;
}
protected int parse_variables() {
return ::parse_variables(
has_index(request_headers, "sec-websocket-key"));
if (!has_index(request_headers, "sec-websocket-key"))
return ::parse_variables();
if (query!="")
.HTTP.Server.http_decode_urlencoded_query(query,variables);
flatten_headers();
return 0;
}
//! Calling @[websocket_accept] completes the WebSocket connection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment