def cbConnected(proto):
     return proto.request(
         Request(method,
                 requestPath,
                 headers,
                 bodyProducer,
                 persistent=self._pool.persistent))
    def allHeadersReceived(self):
        parts = self.status.split(' ', 2)
        if len(parts) != 3:
            raise ParseError("wrong number of parts", self.status)
        method, request_uri, _ = parts

        if method == 'GET':
            self.contentLength = 0
        else:
            self.contentLength = self.parseContentLength(self.connHeaders)
            print "HTTPServerParser Header's Content length", self.contentLength
            # TOFIX: need to include a bodyProducer with the request
            # so that it knows to set a content-length
            self.switchToBodyMode(self._bodyDecoder)
        self.requestParsed(Request(method, request_uri, self.headers, None))
        if self.contentLength == 0:
            self._finished(self.clearLineBuffer())
Beispiel #3
0
    def buildRequest(self):
        """Build the HTTP request used to start this handshake."""
        # Required headers
        headers = {
            "Host": [self.host],
            "Upgrade": ["WebSocket"],
            "Connection": ["Upgrade"],
            "Sec-WebSocket-Key": [self.key],
            "Sec-WebSocket-Version": ["13"]
        }

        # Optional headers
        if self.origin is not None:
            headers["Origin"] = [self.origin]
        if self.protocol is not None:
            headers["Sec-WebSocket-Protocol"] = self.protocol

        return Request("GET",
                       self.path,
                       Headers(headers),
                       bodyProducer=None,
                       persistent=True)
Beispiel #4
0
 def cbConnected(proto):
     # NOTE: For the proxy case the path should be the full URI.
     return proto.request(
         Request(method, request_path, headers, bodyProducer))
Beispiel #5
0
 def cbConnected(proto):
     return proto.request(Request(method, path, headers, bodyProducer))