fix typo
[brisk.git] / web / Obj / transports.phh
index 5f269d7..0cc5f54 100644 (file)
@@ -93,16 +93,18 @@ 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->sendingContinuous = false;
-       $this->sendingContinuous = false;
-       $this->partialMessage = "";
 
-       $this->hasSentClose = false;
+        $this->handlingPartialPacket = false;
+        $this->partialMessage = "";
+
+        $this->hasSentClose = false;
     }
 
     protected function extractHeaders($message) {
@@ -201,6 +203,12 @@ 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);
@@ -386,15 +394,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 {
         }
@@ -410,11 +422,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";
         }
 
@@ -477,6 +491,7 @@ class Transport_websocket {
 class Transport_xhr {
 
     function Transport_xhr() {
+        $this->type = 'xhr';
     }
 
     function init($enc, $header, &$header_out, $init_string, $base, $step)
@@ -517,6 +532,7 @@ class Transport_xhr {
 class Transport_iframe {
 
     function Transport_iframe() {
+        $this->type = 'iframe';
     }
 
     function init($enc, $header, &$header_out, $init_string, $base, $step)
@@ -594,6 +610,9 @@ push(\"%s\");\n// -->\n</script>", $step, escpush($cont) );
 }
 
 class Transport_htmlfile extends Transport_iframe {
+    function Transport_htmlfile() {
+        $this->type = 'htmlfile';
+    }
 }
 
 class Transport {
@@ -603,8 +622,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();
@@ -626,4 +645,4 @@ class Transport {
         }
     }
 }
-?>
\ No newline at end of file
+?>