MCPcopy Create free account
hub / github.com/aws/aws-cli / _handle_expect_response

Method _handle_expect_response

awscli/botocore/awsrequest.py:163–205  ·  view source on GitHub ↗
(self, message_body)

Source from the content-addressed store, hash-verified

161 current = fp.readline()
162
163 def _handle_expect_response(self, message_body):
164 # This is called when we sent the request headers containing
165 # an Expect: 100-continue header and received a response.
166 # We now need to figure out what to do.
167 fp = self.sock.makefile('rb', 0)
168 try:
169 maybe_status_line = fp.readline()
170 parts = maybe_status_line.split(None, 2)
171 if self._is_100_continue_status(maybe_status_line):
172 self._consume_headers(fp)
173 logger.debug(
174 "100 Continue response seen, " "now sending request body."
175 )
176 self._send_message_body(message_body)
177 elif len(parts) == 3 and parts[0].startswith(b'HTTP/'):
178 # From the RFC:
179 # Requirements for HTTP/1.1 origin servers:
180 #
181 # - Upon receiving a request which includes an Expect
182 # request-header field with the "100-continue"
183 # expectation, an origin server MUST either respond with
184 # 100 (Continue) status and continue to read from the
185 # input stream, or respond with a final status code.
186 #
187 # So if we don't get a 100 Continue response, then
188 # whatever the server has sent back is the final response
189 # and don't send the message_body.
190 logger.debug(
191 "Received a non 100 Continue response "
192 "from the server, NOT sending request body."
193 )
194 status_tuple = (
195 parts[0].decode('ascii'),
196 int(parts[1]),
197 parts[2].decode('ascii'),
198 )
199 response_class = functools.partial(
200 AWSHTTPResponse, status_tuple=status_tuple
201 )
202 self.response_class = response_class
203 self._response_received = True
204 finally:
205 fp.close()
206
207 def _send_message_body(self, message_body):
208 if message_body is not None:

Callers 1

_send_outputMethod · 0.95

Calls 6

_consume_headersMethod · 0.95
_send_message_bodyMethod · 0.95
decodeMethod · 0.80
makefileMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected