Here are the examples of the python api aiohttp.errors.BadStatusLine taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
3
Example 1
Project: aiohttp Source File: test_http_parser.py
def test_http_request_parser_bad_status_line(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpRequestParser()(out, buf)
next(p)
self.assertRaises(
errors.BadStatusLine, p.send, b'\r\n\r\n')
3
Example 2
Project: aiohttp Source File: test_http_parser.py
def test_http_request_parser_bad_method(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpRequestParser()(out, buf)
next(p)
self.assertRaises(
errors.BadStatusLine,
p.send, b'!12%()+=~$ /get HTTP/1.1\r\n\r\n')
3
Example 3
Project: aiohttp Source File: test_http_parser.py
def test_http_request_parser_bad_version(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpRequestParser()(out, buf)
next(p)
self.assertRaises(
errors.BadStatusLine,
p.send, b'GET //get HT/11\r\n\r\n')
3
Example 4
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_bad_status_line(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
self.assertRaises(errors.BadStatusLine, p.send, b'\r\n\r\n')
3
Example 5
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_bad_version(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
with self.assertRaises(errors.BadStatusLine) as cm:
p.send(b'HT/11 200 Ok\r\n\r\n')
self.assertEqual('HT/11 200 Ok', cm.exception.args[0])
3
Example 6
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_bad(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
with self.assertRaises(errors.BadStatusLine) as cm:
p.send(b'HTT/1\r\n\r\n')
self.assertIn('HTT/1', str(cm.exception))
3
Example 7
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_code_under_100(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
with self.assertRaises(errors.BadStatusLine) as cm:
p.send(b'HTTP/1.1 99 test\r\n\r\n')
self.assertIn('HTTP/1.1 99 test', str(cm.exception))
3
Example 8
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_code_above_999(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
with self.assertRaises(errors.BadStatusLine) as cm:
p.send(b'HTTP/1.1 9999 test\r\n\r\n')
self.assertIn('HTTP/1.1 9999 test', str(cm.exception))
3
Example 9
Project: aiohttp Source File: test_http_parser.py
def test_http_response_parser_code_not_int(self):
out = aiohttp.FlowControlDataQueue(self.stream)
buf = aiohttp.ParserBuffer()
p = protocol.HttpResponseParser()(out, buf)
next(p)
with self.assertRaises(errors.BadStatusLine) as cm:
p.send(b'HTTP/1.1 ttt test\r\n\r\n')
self.assertIn('HTTP/1.1 ttt test', str(cm.exception))
0
Example 10
Project: aiobotocore Source File: endpoint.py
@asyncio.coroutine
def _get_response(self, request, operation_model, attempts):
# This will return a tuple of (success_response, exception)
# and success_response is itself a tuple of
# (http_response, parsed_dict).
# If an exception occurs then the success_response is None.
# If no exception occurs then exception is None.
try:
# http request substituted too async one
botocore.endpoint.logger.debug("Sending http request: %s", request)
resp = yield from self._request(
request.method, request.url, request.headers, request.body)
http_response = resp
except aiohttp.errors.BadStatusLine:
better_exception = ConnectionClosedError(
endpoint_url=request.url, request=request)
return None, better_exception
except aiohttp.errors.ClientConnectionError as e:
e.request = request # botocore expects the request property
# For a connection error, if it looks like it's a DNS
# lookup issue, 99% of the time this is due to a misconfigured
# region/endpoint so we'll raise a more specific error message
# to help users.
botocore.endpoint.logger.debug("ConnectionError received when "
"sending HTTP request.",
exc_info=True)
if self._looks_like_dns_error(e):
better_exception = EndpointConnectionError(
endpoint_url=request.url, error=e)
return None, better_exception
else:
return None, e
except Exception as e:
botocore.endpoint.logger.debug("Exception received when sending "
"HTTP request.",
exc_info=True)
return None, e
# This returns the http_response and the parsed_data.
response_dict = yield from convert_to_response_dict(
http_response, operation_model)
parser = self._response_parser_factory.create_parser(
operation_model.metadata['protocol'])
return ((http_response, parser.parse(response_dict,
operation_model.output_shape)),
None)