本文整理汇总了Python中future.backports.http.client.BadStatusLine方法的典型用法代码示例。如果您正苦于以下问题:Python client.BadStatusLine方法的具体用法?Python client.BadStatusLine怎么用?Python client.BadStatusLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类future.backports.http.client
的用法示例。
在下文中一共展示了client.BadStatusLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: request
# 需要导入模块: from future.backports.http import client [as 别名]
# 或者: from future.backports.http.client import BadStatusLine [as 别名]
def request(self, host, handler, request_body, verbose=False):
#retry request once if cached connection has gone cold
for i in (0, 1):
try:
return self.single_request(host, handler, request_body, verbose)
except socket.error as e:
if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE):
raise
except http_client.BadStatusLine: #close after we sent request
if i:
raise
示例2: test_status_lines
# 需要导入模块: from future.backports.http import client [as 别名]
# 或者: from future.backports.http.client import BadStatusLine [as 别名]
def test_status_lines(self):
# Test HTTP status lines
body = "HTTP/1.1 200 Ok\r\n\r\nText"
sock = FakeSocket(body)
resp = client.HTTPResponse(sock)
resp.begin()
self.assertEqual(resp.read(), b'Text')
self.assertTrue(resp.isclosed())
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
sock = FakeSocket(body)
resp = client.HTTPResponse(sock)
self.assertRaises(client.BadStatusLine, resp.begin)
示例3: test_bad_status_repr
# 需要导入模块: from future.backports.http import client [as 别名]
# 或者: from future.backports.http.client import BadStatusLine [as 别名]
def test_bad_status_repr(self):
exc = client.BadStatusLine('')
if not utils.PY3:
self.assertEqual(repr(exc), '''BadStatusLine("u\'\'",)''')
else:
self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''')
示例4: test_overflowing_status_line
# 需要导入模块: from future.backports.http import client [as 别名]
# 或者: from future.backports.http.client import BadStatusLine [as 别名]
def test_overflowing_status_line(self):
self.skipTest("disabled for HTTP 0.9 support")
body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
resp = client.HTTPResponse(FakeSocket(body))
self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin)