(self, message_body=None, *args, **kwargs)
| 111 | return msg |
| 112 | |
| 113 | def _send_output(self, message_body=None, *args, **kwargs): |
| 114 | self._buffer.extend((b"", b"")) |
| 115 | msg = self._convert_to_bytes(self._buffer) |
| 116 | del self._buffer[:] |
| 117 | # If msg and message_body are sent in a single send() call, |
| 118 | # it will avoid performance problems caused by the interaction |
| 119 | # between delayed ack and the Nagle algorithm. |
| 120 | if isinstance(message_body, bytes): |
| 121 | msg += message_body |
| 122 | message_body = None |
| 123 | self.send(msg) |
| 124 | if self._expect_header_set: |
| 125 | # This is our custom behavior. If the Expect header was |
| 126 | # set, it will trigger this custom behavior. |
| 127 | logger.debug("Waiting for 100 Continue response.") |
| 128 | # Wait for 1 second for the server to send a response. |
| 129 | if urllib3.util.wait_for_read(self.sock, 1): |
| 130 | self._handle_expect_response(message_body) |
| 131 | return |
| 132 | else: |
| 133 | # From the RFC: |
| 134 | # Because of the presence of older implementations, the |
| 135 | # protocol allows ambiguous situations in which a client may |
| 136 | # send "Expect: 100-continue" without receiving either a 417 |
| 137 | # (Expectation Failed) status or a 100 (Continue) status. |
| 138 | # Therefore, when a client sends this header field to an origin |
| 139 | # server (possibly via a proxy) from which it has never seen a |
| 140 | # 100 (Continue) status, the client SHOULD NOT wait for an |
| 141 | # indefinite period before sending the request body. |
| 142 | logger.debug( |
| 143 | "No response seen from server, continuing to " |
| 144 | "send the response body." |
| 145 | ) |
| 146 | if message_body is not None: |
| 147 | # message_body was not a string (i.e. it is a file), and |
| 148 | # we must run the risk of Nagle. |
| 149 | self.send(message_body) |
| 150 | |
| 151 | def _consume_headers(self, fp): |
| 152 | # Most servers (including S3) will just return |
nothing calls this directly
no test coverage detected