X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Ftransports.phh;h=fcc5c6d23e35102346758a4bc415b9d17d29e032;hb=8b0992347fdfdb40715268bb07481d35fc5191fb;hp=5ebfec470602686c324b30ff9e4f2bdbadf2ec05;hpb=ddd822f1dca51731cc9fc8199db3f1cc527fb01a;p=brisk.git diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index 5ebfec4..fcc5c6d 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -93,16 +93,20 @@ class Transport_template { class Transport_websocket { protected $magicGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - function Transport_websocket() { + function Transport_websocket($secure = FALSE) { + $this->type = ($secure == FALSE ? "websocket" : "websocketsec"); $this->headerOriginRequired = false; $this->headerSecWebSocketProtocolRequired = false; $this->headerSecWebSocketExtensionsRequired = false; + $this->handlingPartialPacket = false; + $this->sendingContinuous = false; - $this->sendingContinuous = false; - $this->partialMessage = ""; - $this->hasSentClose = false; + $this->handlingPartialPacket = false; + $this->partialMessage = ""; + + $this->hasSentClose = false; } protected function extractHeaders($message) { @@ -201,8 +205,15 @@ class Transport_websocket { return $strout . "\n"; } + function unchunk($cont) + { + // fprintf(STDERR, "CHUNK: [%s]\n", $cont); + return $this->deframe($cont); + } + function chunk($step, $cont) { + // fprintf(STDERR, "CHUNK: [%s]\n", $cont); return $this->frame('@BEGIN@'.$cont.'@END@'); // , 'text', TRUE); } @@ -385,15 +396,19 @@ class Transport_websocket { } if (!isset($headers['Host']) || !$this->checkHost($headers['Host'])) { + // error_log('bad 1'); $headers_out['HTTP-Response'] = "400 Bad Request"; } if (!isset($headers['Upgrade']) || strtolower($headers['Upgrade']) != 'websocket') { + // error_log('bad 2 ' . $headers['Upgrade']); $headers_out['HTTP-Response'] = "400 Bad Request"; } if (!isset($headers['Connection']) || strpos(strtolower($headers['Connection']), 'upgrade') === FALSE) { + // error_log('bad 3'); $headers_out['HTTP-Response'] = "400 Bad Request"; } if (!isset($headers['Sec-Websocket-Key'])) { + // error_log('bad 4'); $headers_out['HTTP-Response'] = "400 Bad Request"; } else { } @@ -409,11 +424,13 @@ class Transport_websocket { if ( ($this->headerSecWebSocketProtocolRequired && !isset($headers['Sec-Websocket-Protocol'])) || ($this->headerSecWebSocketProtocolRequired && !$this->checkWebsocProtocol($headers['Sec-Websocket-Protocol']))) { + // error_log('bad 5'); $headers_out['HTTP-Response'] = "400 Bad Request"; } if ( ($this->headerSecWebSocketExtensionsRequired && !isset($headers['Sec-Websocket-Extensions'])) || ($this->headerSecWebSocketExtensionsRequired && !$this->checkWebsocExtensions($headers['Sec-Websocket-Extensions'])) ) { + // error_log('bad 6'); $headers_out['HTTP-Response'] = "400 Bad Request"; } @@ -476,6 +493,7 @@ class Transport_websocket { class Transport_xhr { function Transport_xhr() { + $this->type = 'xhr'; } function init($enc, $header, &$header_out, $init_string, $base, $step) @@ -503,6 +521,7 @@ class Transport_xhr { function chunk($step, $cont) { + // fprintf(STDERR, "CHUNK: [%s]\n", $cont); return ("@BEGIN@".$cont."@END@"); } @@ -515,6 +534,7 @@ class Transport_xhr { class Transport_iframe { function Transport_iframe() { + $this->type = 'iframe'; } function init($enc, $header, &$header_out, $init_string, $base, $step) @@ -574,6 +594,7 @@ push(\"%s\"); function chunk($step, $cont) { + // fprintf(STDERR, "CHUNK: [%s]\n", $cont); if ($cont == NULL) { return sprintf("", $step); @@ -591,6 +612,9 @@ push(\"%s\");\n// -->\n", $step, escpush($cont) ); } class Transport_htmlfile extends Transport_iframe { + function Transport_htmlfile() { + $this->type = 'htmlfile'; + } } class Transport { @@ -600,8 +624,8 @@ class Transport { static function create($transp) { - if ($transp == 'websocket') { - return new Transport_websocket(); + if ($transp == 'websocket' || $transp == 'websocketsec') { + return new Transport_websocket($transp == 'websocketsec'); } else if ($transp == 'xhr') { return new Transport_xhr(); @@ -623,4 +647,4 @@ class Transport { } } } -?> \ No newline at end of file +?>