def on_http_req(self, req_header, req_body): """ :type req_header: HttpRequestHeader :type req_body: bytes """ if self.parse_config.level == OutputLevel.ONLY_URL: self._println(req_header.method + b" " + _get_full_url(req_header.uri, req_header.host)) elif self.parse_config.level == OutputLevel.HEADER: self._println(req_header.raw_data) self._println() elif self.parse_config.level >= OutputLevel.TEXT_BODY: self._println(req_header.raw_data) #self._println() self.uri = req_header.uri self.req_head = req_header.raw_data self.host = req_header.host self.referer = req_header.referer mime, charset = utils.parse_content_type(req_header.content_type) # usually charset is not set in http post output_body = self._if_output(mime) if self.parse_config.encoding and not charset: charset = self.parse_config.encoding if req_header.compress == Compress.IDENTITY: # if is gzip by content magic header # someone missed the content-encoding header if utils.gzipped(req_body): req_header.compress = Compress.GZIP if output_body: self._print_body(req_body, req_header.compress, mime, charset)
def on_http_resp(self, resp_header, resp_body): """ :type resp_header: HttpResponseHeader :type resp_body: bytes """ if self.parse_config.level == OutputLevel.ONLY_URL: self._println(resp_header.status_line) elif self.parse_config.level == OutputLevel.HEADER: self._println(resp_header.raw_data) self._println() elif self.parse_config.level >= OutputLevel.TEXT_BODY: self._println(resp_header.raw_data) self._println() mime, charset = utils.parse_content_type(resp_header.content_type) # usually charset is not set in http post output_body = self._if_output(mime) if self.parse_config.encoding and not charset: charset = self.parse_config.encoding if not resp_header.gzip: # if is gzip by content magic header # someone missed the content-encoding header resp_header.gzip = utils.gzipped(resp_body) if output_body: self._print_body(resp_body, resp_header.gzip, mime, charset) self._println() if not config.get_config().group: self._do_output()
def on_http_resp(self, resp_header, resp_body, orig_chunked_resp, header_dict): """ :type resp_header: HttpResponseHeader :type resp_body: bytes """ self.res_headerdict = header_dict if self.parse_config.level == OutputLevel.ONLY_URL: self._println(resp_header.status_line) elif self.parse_config.level == OutputLevel.HEADER: self._println(resp_header.raw_data) self._println() elif self.parse_config.level >= OutputLevel.TEXT_BODY: self._println(resp_header.raw_data) #self._println() self.res_head = resp_header.raw_data self.orig_chunked_resp = orig_chunked_resp self.res_type = resp_header.content_type self.res_len = resp_header.content_len self.res_num = resp_header.status_line[resp_header.status_line. find(' ') + 1:] self.redirect_to = resp_header.redirect_to self.filename = resp_header.filename mime, charset = utils.parse_content_type(resp_header.content_type) # usually charset is not set in http post output_body = self._if_output(mime) if self.parse_config.encoding and not charset: charset = self.parse_config.encoding if resp_header.compress == Compress.IDENTITY: # if is gzip by content magic header # someone missed the content-encoding header if utils.gzipped(resp_body): resp_header.compress = Compress.GZIP if output_body: self._print_body(resp_body, resp_header.compress, mime, charset) #self._println() self.orig_resp = resp_body if self.res_body == b"": self.res_body = resp_body if (self.res_body is not None) and (len(self.res_body) > 0) and (self.res_len == 0): self.res_len = len(self.res_body) if not config.get_config().group: self._do_output()
def on_http_resp(self, resp_header, resp_body, orig_chunked_resp, header_dict): """ :type resp_header: HttpResponseHeader :type resp_body: bytes """ self.res_headerdict = header_dict if self.parse_config.level == OutputLevel.ONLY_URL: self._println(resp_header.status_line) elif self.parse_config.level == OutputLevel.HEADER: self._println(resp_header.raw_data) self._println() elif self.parse_config.level >= OutputLevel.TEXT_BODY: self._println(resp_header.raw_data) #self._println() self.res_head = resp_header.raw_data self.orig_chunked_resp = orig_chunked_resp self.res_type = resp_header.content_type self.res_len = resp_header.content_len self.res_num = resp_header.status_line[resp_header.status_line.find(' ') + 1:] self.redirect_to = resp_header.redirect_to self.filename = resp_header.filename mime, charset = utils.parse_content_type(resp_header.content_type) # usually charset is not set in http post output_body = self._if_output(mime) if self.parse_config.encoding and not charset: charset = self.parse_config.encoding if resp_header.compress == Compress.IDENTITY: # if is gzip by content magic header # someone missed the content-encoding header if utils.gzipped(resp_body): resp_header.compress = Compress.GZIP if output_body: self._print_body(resp_body, resp_header.compress, mime, charset) #self._println() self.orig_resp = resp_body if self.res_body == b"": self.res_body = resp_body if (self.res_body is not None) and (len(self.res_body) > 0) and (self.res_len == 0): self.res_len = len(self.res_body) if not config.get_config().group: self._do_output()
def on_http_req(self, req_header, req_body, header_dict): """ :type req_header: HttpRequestHeader :type req_body: bytes """ self.req_headerdict = header_dict if self.parse_config.level == OutputLevel.ONLY_URL: self._println(req_header.method + b" " + _get_full_url(req_header.uri, req_header.host)) elif self.parse_config.level == OutputLevel.HEADER: self._println(req_header.raw_data) self._println() elif self.parse_config.level >= OutputLevel.TEXT_BODY: self._println(req_header.raw_data) #self._println() self.uri = req_header.uri if req_body is None: req_body = "" else: req_body = "\r\n\r\n" + req_body self.req = req_header.raw_data + req_body self.req_head = req_header.raw_data self.host = req_header.host self.referer = req_header.referer self.user_agent = req_header.user_agent self.method = req_header.method self.time = req_header.time mime, charset = utils.parse_content_type(req_header.content_type) # usually charset is not set in http post output_body = self._if_output(mime) if self.parse_config.encoding and not charset: charset = self.parse_config.encoding if req_header.compress == Compress.IDENTITY: # if is gzip by content magic header # someone missed the content-encoding header if utils.gzipped(req_body): req_header.compress = Compress.GZIP if output_body: self.req_body = req_body if (self.req_body is not None) and (len(self.req_body) > 0) and (self.req_len == 0): self.req_len = len(self.req_body) self._print_body(req_body, req_header.compress, mime, charset)