Esempio n. 1
0
 def http_response(self, request, response):
     if not hasattr(response, "seek"):
         response = response_seek_wrapper(response)
     info = logging.getLogger("mechanize.http_responses").info
     try:
         info(response.read())
     finally:
         response.seek(0)
     info("*****************************************************")
     return response
Esempio n. 2
0
 def http_response(self, request, response):
     if not hasattr(response, "seek"):
         response = response_seek_wrapper(response)
     info = logging.getLogger("mechanize.http_responses").info
     try:
         info(response.read())
     finally:
         response.seek(0)
     info("*****************************************************")
     return response
Esempio n. 3
0
 def http_response(self, request, response):
     if not hasattr(response, "seek"):
         response = response_seek_wrapper(response)
     http_message = response.info()
     url = response.geturl()
     ct_hdrs = http_message.getheaders("content-type")
     if is_html(ct_hdrs, url, self._allow_xhtml):
         try:
             try:
                 html_headers = parse_head(response, self.head_parser_class())
             finally:
                 response.seek(0)
         except (HTMLParser.HTMLParseError, sgmllib.SGMLParseError):
             pass
         else:
             for hdr, val in html_headers:
                 # add a header
                 http_message.dict[hdr.lower()] = val
                 text = hdr + ": " + val
                 for line in text.split("\n"):
                     http_message.headers.append(line + "\n")
     return response
Esempio n. 4
0
 def http_response(self, request, response):
     if not hasattr(response, "seek"):
         response = response_seek_wrapper(response)
     http_message = response.info()
     url = response.geturl()
     ct_hdrs = http_message.getheaders("content-type")
     if is_html(ct_hdrs, url, self._allow_xhtml):
         try:
             try:
                 html_headers = parse_head(response, self.head_parser_class())
             finally:
                 response.seek(0)
         except (HTMLParser.HTMLParseError,
                 sgmllib.SGMLParseError):
             pass
         else:
             for hdr, val in html_headers:
                 # add a header
                 http_message.dict[hdr.lower()] = val
                 text = hdr + ": " + val
                 for line in text.split("\n"):
                     http_message.headers.append(line + "\n")
     return response
Esempio n. 5
0
 def any_response(self, request, response):
     if not hasattr(response, "seek"):
         return response_seek_wrapper(response)
     return response
Esempio n. 6
0
 def any_response(self, request, response):
     if not hasattr(response, "seek"):
         return response_seek_wrapper(response)
     return response