Esempio n. 1
0
    def read_request(self):
        self.request_data_finished.wait()

        if self.zombie:  # pragma: no cover
            raise exceptions.Http2ProtocolException("Zombie Stream")

        data = []
        while self.request_data_queue.qsize() > 0:
            data.append(self.request_data_queue.get())
        data = b"".join(data)

        first_line_format, method, scheme, host, port, path = http2.parse_headers(self.request_headers)

        return models.HTTPRequest(
            first_line_format,
            method,
            scheme,
            host,
            port,
            path,
            b"HTTP/2.0",
            self.request_headers,
            data,
            timestamp_start=self.timestamp_start,
            timestamp_end=self.timestamp_end,
        )
Esempio n. 2
0
    def read_request(self):
        self.request_data_finished.wait()

        if self.zombie:  # pragma: no cover
            raise exceptions.Http2ProtocolException("Zombie Stream")

        authority = self.request_headers.get(':authority', '')
        method = self.request_headers.get(':method', 'GET')
        scheme = self.request_headers.get(':scheme', 'https')
        path = self.request_headers.get(':path', '/')
        self.request_headers.clear(":method")
        self.request_headers.clear(":scheme")
        self.request_headers.clear(":path")
        host = None
        port = None

        if path == '*' or path.startswith("/"):
            first_line_format = "relative"
        elif method == 'CONNECT':  # pragma: no cover
            raise NotImplementedError("CONNECT over HTTP/2 is not implemented.")
        else:  # pragma: no cover
            first_line_format = "absolute"
            # FIXME: verify if path or :host contains what we need
            scheme, host, port, _ = netlib.http.url.parse(path)

        if authority:
            host, _, port = authority.partition(':')

        if not host:
            host = 'localhost'
        if not port:
            port = 443 if scheme == 'https' else 80
        port = int(port)

        data = []
        while self.request_data_queue.qsize() > 0:
            data.append(self.request_data_queue.get())
        data = b"".join(data)

        return models.HTTPRequest(
            first_line_format,
            method,
            scheme,
            host,
            port,
            path,
            b"HTTP/2.0",
            self.request_headers,
            data,
            timestamp_start=self.timestamp_start,
            timestamp_end=self.timestamp_end,
        )
Esempio n. 3
0
    def create_request(self, method, scheme, host, port, path):
        """
            this method creates a new artificial and minimalist request also adds it to flowlist
        """
        c = models.ClientConnection.make_dummy(("", 0))
        s = models.ServerConnection.make_dummy((host, port))

        f = models.HTTPFlow(c, s)
        headers = models.Headers()

        req = models.HTTPRequest("absolute", method, scheme, host, port, path,
                                 b"HTTP/1.1", headers, b"")
        f.request = req
        self.load_flow(f)
        return f
Esempio n. 4
0
 def read_request_headers(self):
     self.request_arrived.wait()
     self.raise_zombie()
     first_line_format, method, scheme, host, port, path = http2.parse_headers(
         self.request_headers)
     return models.HTTPRequest(
         first_line_format,
         method,
         scheme,
         host,
         port,
         path,
         b"HTTP/2.0",
         self.request_headers,
         None,
         timestamp_start=self.timestamp_start,
         timestamp_end=self.timestamp_end,
     )
Esempio n. 5
0
    def read_request(self):
        self.request_data_finished.wait()

        data = []
        while self.request_data_queue.qsize() > 0:
            data.append(self.request_data_queue.get())
        data = b"".join(data)

        first_line_format, method, scheme, host, port, path = http2.parse_headers(
            self.request_headers)

        return models.HTTPRequest(
            first_line_format,
            method,
            scheme,
            host,
            port,
            path,
            b"HTTP/2.0",
            self.request_headers,
            data,
            timestamp_start=self.timestamp_start,
            timestamp_end=self.timestamp_end,
        )