Ejemplo n.º 1
0
    async def send(self, request: Request) -> Response:
        if not self.open:
            # NB: if the connection is closed here, it is always possible to
            # try again with a new connection
            # instead, if it happens later; we cannot retry because we started
            # sending a request
            raise ConnectionClosedError(True)

        self.request = request
        self._pending_task = True

        if request_has_body(request) and request.expect_100_continue():
            # don't send the body immediately; instead, wait for HTTP 100
            # Continue interim response from server
            self.expect_100_continue = True
            self.transport.write(write_request_without_body(request))

            return await self._wait_response()

        if is_small_request(request):
            self.transport.write(write_small_request(request))
        else:
            response = await self._write_chunks(request, write_request)

            if response is not None:
                # this happens if the server sent a response before we completed
                # sending a body
                return response

        return await self._wait_response()
Ejemplo n.º 2
0
def test_request_expect_100_continue(header, expected_result):
    request = Request("POST", b"/", [header])
    assert expected_result == request.expect_100_continue()
Ejemplo n.º 3
0
def test_request_expect_100_continue(header, expected_result):
    request = Request('POST', b'/', [header])
    assert expected_result == request.expect_100_continue()
Ejemplo n.º 4
0
def test_request_expect_100_continue(header, expected_result):
    request = Request(b'POST', b'/', Headers([header]), None)
    assert expected_result == request.expect_100_continue()