當前位置: 首頁>>代碼示例>>Python>>正文


Python HTTPStatus.SEE_OTHER屬性代碼示例

本文整理匯總了Python中http.HTTPStatus.SEE_OTHER屬性的典型用法代碼示例。如果您正苦於以下問題:Python HTTPStatus.SEE_OTHER屬性的具體用法?Python HTTPStatus.SEE_OTHER怎麽用?Python HTTPStatus.SEE_OTHER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在http.HTTPStatus的用法示例。


在下文中一共展示了HTTPStatus.SEE_OTHER屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: see_other

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import SEE_OTHER [as 別名]
def see_other(headers: Sequence[Header] = (), **kwargs: Any) -> Response:
    return Response(
        status=HTTPStatus.SEE_OTHER,
        headers=headers,
        content_type=None,
        body=None,
        ctx=kwargs,
    ) 
開發者ID:dutradda,項目名稱:apidaora,代碼行數:10,代碼來源:responses.py

示例2: make_see_other_response

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import SEE_OTHER [as 別名]
def make_see_other_response(
    headers: Optional[ASGIHeaders] = None,
) -> ASGIResponse:
    return make_response(
        None, HTTPStatus.SEE_OTHER, headers, SEE_OTHER_RESPONSE, None,
    ) 
開發者ID:dutradda,項目名稱:apidaora,代碼行數:8,代碼來源:responses.py

示例3: __init__

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import SEE_OTHER [as 別名]
def __init__(self, url: str, status_code: int, text: str, headers: dict = None):
        self.status_code = status_code
        self.url = url
        self.text = text
        self.headers = dict()
        self.is_redirect = status_code == HTTPStatus.SEE_OTHER
        if headers is not None:
            self.headers.update(headers) 
開發者ID:cloudfoundry-community,項目名稱:cf-python-client,代碼行數:10,代碼來源:fake_requests.py

示例4: _handle_redirects

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import SEE_OTHER [as 別名]
def _handle_redirects(self, response, data='', content_type='', **extra):
        """
        Follow any redirects by requesting responses from the server using GET.
        """
        response.redirect_chain = []
        redirect_status_codes = (
            HTTPStatus.MOVED_PERMANENTLY,
            HTTPStatus.FOUND,
            HTTPStatus.SEE_OTHER,
            HTTPStatus.TEMPORARY_REDIRECT,
            HTTPStatus.PERMANENT_REDIRECT,
        )
        while response.status_code in redirect_status_codes:
            response_url = response.url
            redirect_chain = response.redirect_chain
            redirect_chain.append((response_url, response.status_code))

            url = urlsplit(response_url)
            if url.scheme:
                extra['wsgi.url_scheme'] = url.scheme
            if url.hostname:
                extra['SERVER_NAME'] = url.hostname
            if url.port:
                extra['SERVER_PORT'] = str(url.port)

            # Prepend the request path to handle relative path redirects
            path = url.path
            if not path.startswith('/'):
                path = urljoin(response.request['PATH_INFO'], path)

            if response.status_code in (HTTPStatus.TEMPORARY_REDIRECT, HTTPStatus.PERMANENT_REDIRECT):
                # Preserve request method post-redirect for 307/308 responses.
                request_method = getattr(self, response.request['REQUEST_METHOD'].lower())
            else:
                request_method = self.get
                data = QueryDict(url.query)
                content_type = None

            response = request_method(path, data=data, content_type=content_type, follow=False, **extra)
            response.redirect_chain = redirect_chain

            if redirect_chain[-1] in redirect_chain[:-1]:
                # Check that we're not redirecting to somewhere we've already
                # been to, to prevent loops.
                raise RedirectCycleError("Redirect loop detected.", last_response=response)
            if len(redirect_chain) > 20:
                # Such a lengthy chain likely also means a loop, but one with
                # a growing path, changing view, or changing query argument;
                # 20 is the value of "network.http.redirection-limit" from Firefox.
                raise RedirectCycleError("Too many redirects.", last_response=response)

        return response 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:54,代碼來源:client.py


注:本文中的http.HTTPStatus.SEE_OTHER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。