aptdetector/network/parser/httpparser.py
def read_http_req_header(self, reader):
        """read & parse request http headers

        Args:
            reader (DataReader): type of reader that is required
        Returns:
            `None` if not a response or any error happend , `dict` of parsed_header otherwise
        """
        line = reader.read_line()
        if line is None:
            return None
        line = line.strip()
        if not utils.is_request(line):
            return None

        req_header = HttpRequestHeader()
        items = line.split(b' ')
        if len(items) == 3:
            req_header.method = items[0]
            req_header.uri = items[1]
            req_header.protocol = items[2]

        lines = [line]
        header_dict = self.read_headers(reader, lines)
        if b"content-length" in header_dict:
            req_header.content_len = int(header_dict[b"content-length"])
        if b"transfer-encoding" in header_dict and b'chunked' in header_dict[
                b"transfer-encoding"]:
            req_header.chunked = True
        req_header.content_type = header_dict[b'content-type']
        req_header.compress = utils.get_compress_type(header_dict[
            b"content-encoding"])
        req_header.host = header_dict[b"host"]
        if b'expect' in header_dict:
            req_header.expect = header_dict[b'expect']

        req_header.raw_data = b'\n'.join(lines)
        return req_header
read & parse request http headers

        Args:
            reader (DataReader): type of reader that is required
        Returns:
            `None` if not a response or any error happend , `dict` of parsed_header otherwise
        
read & parse request http headers
read & parse request http headers
def read_http_req_header(self, reader):
        line = reader.read_line()
        if line is None:
            return None
        line = line.strip()
        if not utils.is_request(line):
            return None
        req_header = HttpRequestHeader()
        items = line.split(b' ')
        if len(items) == 3:
            req_header.method = items[0]
            req_header.uri = items[1]
            req_header.protocol = items[2]
        lines = [line]
        header_dict = self.read_headers(reader, lines)
        if b"content-length" in header_dict:
            req_header.content_len = int(header_dict[b"content-length"])
        if b"transfer-encoding" in header_dict and b'chunked' in header_dict[
                b"transfer-encoding"]:
            req_header.chunked = True
        req_header.content_type = header_dict[b'content-type']
        req_header.compress = utils.get_compress_type(header_dict[
            b"content-encoding"])
        req_header.host = header_dict[b"host"]
        if b'expect' in header_dict:
            req_header.expect = header_dict[b'expect']
        req_header.raw_data = b'\n'.join(lines)
        return req_header
def read_http_req_header ( self , reader ) : line = reader . read_line ( ) if line is None : return None line = line . strip ( ) if not utils . is_request ( line ) : return None req_header = HttpRequestHeader ( ) items = line . split ( b' ' ) if len ( items ) == 3 : req_header . method = items [ 0 ] req_header . uri = items [ 1 ] req_header . protocol = items [ 2 ] lines = [ line ] header_dict = self . read_headers ( reader , lines ) if b"content-length" in header_dict : req_header . content_len = int ( header_dict [ b"content-length" ] ) if b"transfer-encoding" in header_dict and b'chunked' in header_dict [ b"transfer-encoding" ] : req_header . chunked = True req_header . content_type = header_dict [ b'content-type' ] req_header . compress = utils . get_compress_type ( header_dict [ b"content-encoding" ] ) req_header . host = header_dict [ b"host" ] if b'expect' in header_dict : req_header . expect = header_dict [ b'expect' ] req_header . raw_data = b'\n' . join ( lines ) return req_header
read & parse request http headers
read & parse request http headers
"""read & parse request http headers

        Args:
            reader (DataReader): type of reader that is required
        Returns:
            `None` if not a response or any error happend , `dict` of parsed_header otherwise
        """
`None` if not a response or any error happend , `dict` of parsed_header otherwise
` None ` if not a response or any error happend ` dict ` of parsed_header otherwise
self
reader
type of reader that is required
type of reader that is required