Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awscli/botocore/awsrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _is_100_continue_status(self, maybe_status_line):
parts = maybe_status_line.split(None, 2)
# Check for HTTP/<version> 100 Continue\r\n
return (
len(parts) >= 3
len(parts) >= 2
and parts[0].startswith(b'HTTP/')
and parts[1] == b'100'
)
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/botocore/test_awsrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,33 @@ def test_expect_100_sends_connection_header(self):
response = conn.getresponse()
self.assertEqual(response.status, 500)

def test_expect_100_sends_connection_header_optional_continue(self):
# When using squid as an HTTP proxy, it will also send
# a Connection: keep-alive header back with the 100 continue
# response. We need to ensure we handle this case.
with mock.patch('urllib3.util.wait_for_read') as wait_mock:
# Shows the server first sending a 100 continue response
# then a 500 response. We're picking 500 to confirm we
# actually parse the response instead of getting the
# default status of 200 which happens when we can't parse
# the response.
s = FakeSocket(
b'HTTP/1.1 100\r\n' # HTTP/<version> 100\r\n - excluding reason "Continue"
b'Connection: keep-alive\r\n'
b'\r\n'
b'HTTP/1.1 500 Internal Service Error\r\n'
)
conn = AWSHTTPConnection('s3.amazonaws.com', 443)
conn.sock = s
wait_mock.return_value = True
conn.request(
'GET', '/bucket/foo', b'body', {'Expect': b'100-continue'}
)
# Assert that we waited for the 100-continue response
self.assertEqual(wait_mock.call_count, 1)
response = conn.getresponse()
self.assertEqual(response.status, 500)

def test_expect_100_continue_sends_307(self):
# This is the case where we send a 100 continue and the server
# immediately sends a 307
Expand Down
Loading