本文整理匯總了Python中http.client.LineTooLong方法的典型用法代碼示例。如果您正苦於以下問題:Python client.LineTooLong方法的具體用法?Python client.LineTooLong怎麽用?Python client.LineTooLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類http.client
的用法示例。
在下文中一共展示了client.LineTooLong方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: headers_factory
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import LineTooLong [as 別名]
def headers_factory(fp, *args):
try:
ret = client.parse_headers(fp, _class=OldMessage)
except client.LineTooLong:
ret = OldMessage()
ret.status = 'Line too long'
return ret
示例2: test_overflowing_status_line
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import LineTooLong [as 別名]
def test_overflowing_status_line(self):
body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
resp = client.HTTPResponse(FakeSocket(body))
self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin)
示例3: test_overflowing_header_line
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import LineTooLong [as 別名]
def test_overflowing_header_line(self):
body = (
'HTTP/1.1 200 OK\r\n'
'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n'
)
resp = client.HTTPResponse(FakeSocket(body))
self.assertRaises(client.LineTooLong, resp.begin)
示例4: test_overflowing_chunked_line
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import LineTooLong [as 別名]
def test_overflowing_chunked_line(self):
body = (
'HTTP/1.1 200 OK\r\n'
'Transfer-Encoding: chunked\r\n\r\n'
+ '0' * 65536 + 'a\r\n'
'hello world\r\n'
'0\r\n'
'\r\n'
)
resp = client.HTTPResponse(FakeSocket(body))
resp.begin()
self.assertRaises(client.LineTooLong, resp.read)
示例5: test_overflowing_chunked_line
# 需要導入模塊: from http import client [as 別名]
# 或者: from http.client import LineTooLong [as 別名]
def test_overflowing_chunked_line(self):
body = (
'HTTP/1.1 200 OK\r\n'
'Transfer-Encoding: chunked\r\n\r\n'
+ '0' * 65536 + 'a\r\n'
'hello world\r\n'
'0\r\n'
)
resp = client.HTTPResponse(FakeSocket(body))
resp.begin()
self.assertRaises(client.LineTooLong, resp.read)