Beispiel #1
0
 def fetch_url(self, fetch_url, **kwargs):
     try:
         response = yield fetch_and_trace_response(fetch_url, **kwargs)
     except HTTPError as e:
         yield self.handle_fetch_exception(e, fetch_url)
         raise gen.Return()
     raise gen.Return(response)
Beispiel #2
0
 def fetch_url(self, fetch_url, skip_except_handle=False, **kwargs):
     try:
         response = yield fetch_and_trace_response(fetch_url, **kwargs)
     except HTTPError as e:
         if not skip_except_handle:
             yield self.handle_fetch_exception(e, fetch_url)
         raise gen.Return()
     raise gen.Return(response)
Beispiel #3
0
    def fetch_and_redirect(self, fetch_url, **kwargs):
        """处了fetch_url,其他的必须使用kwargs传递"""
        try:
            response = yield fetch_and_trace_response(fetch_url, **kwargs)
        except HTTPError as e:
            yield self.handle_fetch_exception(e, fetch_url)
            raise gen.Return()

        yield self.response_redirect(
            response.code, body=response.body,
            content_type=response.headers.get("Content-Type", None))
        raise gen.Return()
Beispiel #4
0
    def fetch_and_redirect(self, fetch_url, **kwargs):
        """处了fetch_url,其他的必须使用kwargs传递"""
        try:
            response = yield fetch_and_trace_response(fetch_url, **kwargs)
        except HTTPError as e:
            yield self.handle_fetch_exception(e, fetch_url)
            raise gen.Return()

        yield self.response_redirect(response.code,
                                     body=response.body,
                                     content_type=response.headers.get(
                                         "Content-Type", None))
        raise gen.Return()