Ejemplo n.º 1
0
 def recv(self):
     """
     Receives a raw mongrel2.handler.Request object that you
     can then work with.
     """
     return Request.parse(self.reqs.recv())
Ejemplo n.º 2
0
        if (w_type == "ping"):
            conn.send(msg_parts[0], msg_parts[1],
                  handler.websocket_response("", wsutil.OP_PING))

        elif (w_type == "pub"):
            conn.send(msg_parts[0], msg_parts[1],
                  handler.websocket_response(json.dumps(msg_parts[3:])))

        elif (w_type == "close"):
            conn.send(msg_parts[0], msg_parts[1],
                handler.websocket_response('', wsutil.OP_CLOSE))
            print "closed connection"

    if conn.reqs in socks:
        req = Request.parse(conn.reqs.recv())

        if req.is_disconnect():
            #print "DISCONNECTED", req.conn_id
            continue
    
        if req.headers.get('METHOD') == 'WEBSOCKET_HANDSHAKE':
            #print "HANDSHAKE"
            conn.reply(req,
                    '\r\n'.join([
                        "HTTP/1.1 101 Switching Protocols",
                        "Upgrade: WebSocket",
                        "Connection: Upgrade",
                        "WebSocket-Origin: http://localhost:6767",
                        "WebSocket-Location: ws://localhost:6767/sub",
                        "Sec-WebSocket-Accept: %s\r\n\r\n"]) %(req.body))
Ejemplo n.º 3
0
 def recv(self):
     """
     Receives a raw mongrel2.handler.Request object that you
     can then work with.
     """
     return Request.parse(self.reqs.recv())
Ejemplo n.º 4
0
 def recv(self):
     req_str = self.reqs.recv()
     print(req_str)
     return Request.parse(req_str)