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


Python HTTPStatus.HTTP_VERSION_NOT_SUPPORTED屬性代碼示例

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


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

示例1: test_version_invalid

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import HTTP_VERSION_NOT_SUPPORTED [as 別名]
def test_version_invalid(self):
        self.con._http_vsn = 99
        self.con._http_vsn_str = 'HTTP/9.9'
        self.con.putrequest('GET', '/')
        self.con.endheaders()
        res = self.con.getresponse()
        self.assertEqual(res.status, HTTPStatus.HTTP_VERSION_NOT_SUPPORTED) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:9,代碼來源:test_httpservers.py

示例2: test_http_status_to_canonical_code

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import HTTP_VERSION_NOT_SUPPORTED [as 別名]
def test_http_status_to_canonical_code(self):
        for status_code, expected in (
            (HTTPStatus.OK, StatusCanonicalCode.OK),
            (HTTPStatus.ACCEPTED, StatusCanonicalCode.OK),
            (HTTPStatus.IM_USED, StatusCanonicalCode.OK),
            (HTTPStatus.MULTIPLE_CHOICES, StatusCanonicalCode.OK),
            (HTTPStatus.BAD_REQUEST, StatusCanonicalCode.INVALID_ARGUMENT),
            (HTTPStatus.UNAUTHORIZED, StatusCanonicalCode.UNAUTHENTICATED),
            (HTTPStatus.FORBIDDEN, StatusCanonicalCode.PERMISSION_DENIED),
            (HTTPStatus.NOT_FOUND, StatusCanonicalCode.NOT_FOUND),
            (
                HTTPStatus.UNPROCESSABLE_ENTITY,
                StatusCanonicalCode.INVALID_ARGUMENT,
            ),
            (
                HTTPStatus.TOO_MANY_REQUESTS,
                StatusCanonicalCode.RESOURCE_EXHAUSTED,
            ),
            (HTTPStatus.NOT_IMPLEMENTED, StatusCanonicalCode.UNIMPLEMENTED),
            (HTTPStatus.SERVICE_UNAVAILABLE, StatusCanonicalCode.UNAVAILABLE),
            (
                HTTPStatus.GATEWAY_TIMEOUT,
                StatusCanonicalCode.DEADLINE_EXCEEDED,
            ),
            (
                HTTPStatus.HTTP_VERSION_NOT_SUPPORTED,
                StatusCanonicalCode.INTERNAL,
            ),
            (600, StatusCanonicalCode.UNKNOWN),
            (99, StatusCanonicalCode.UNKNOWN),
        ):
            with self.subTest(status_code=status_code):
                actual = http_status_to_canonical_code(int(status_code))
                self.assertEqual(actual, expected, status_code) 
開發者ID:open-telemetry,項目名稱:opentelemetry-python,代碼行數:36,代碼來源:test_utils.py


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