http.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:eater 作者: alexhayes 项目源码 文件源码
def request(self, **kwargs) -> Model:
        """
        Make a HTTP request of of type method.

        You should generally leave this method alone. If you need to customise the behaviour use the methods that
        this method uses.
        """
        kwargs = self.get_request_kwargs(request_model=self.request_model, **kwargs)

        # get_request_kwargs can permanently alter the url, method and session
        self.url = kwargs.pop('url', self.url)
        self.method = kwargs.pop('method', self.method)
        self.session = kwargs.pop('session', self.session)

        try:
            response = getattr(self.session, self.method)(self.url, **kwargs)
            return self.create_response_model(response, self.request_model)

        except requests.Timeout:
            raise EaterTimeoutError("%s.%s for URL '%s' timed out." % (
                type(self).__name__,
                self.method,
                self.url
            ))

        except requests.RequestException as exc_info:
            raise EaterConnectError("Exception raised for URL '%s'." % self.url) from exc_info
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号