response = await client.delete(url)
assert response.status_code == 200
assert response.text == "Hello, world!"
+
+
+@pytest.mark.asyncio
+async def test_100_continue(server):
+ url = "http://127.0.0.1:8000/echo_body"
+ headers = {"Expect": "100-continue"}
+ data = b"Echo request body"
+
+ async with httpcore.AsyncClient() as client:
+ response = await client.post(url, headers=headers, data=data)
+
+ assert response.status_code == 200
+ assert response.content == data
await slow_response(scope, receive, send)
elif scope["path"].startswith("/status"):
await status_code(scope, receive, send)
+ elif scope["path"].startswith("/echo_body"):
+ await echo_body(scope, receive, send)
else:
await hello_world(scope, receive, send)
await send({"type": "http.response.body", "body": b"Hello, world!"})
+async def echo_body(scope, receive, send):
+ body = b''
+ more_body = True
+
+ while more_body:
+ message = await receive()
+ body += message.get('body', b'')
+ more_body = message.get('more_body', False)
+
+ await send(
+ {
+ "type": "http.response.start",
+ "status": 200,
+ "headers": [[b"content-type", b"text/plain"]],
+ }
+ )
+ await send({"type": "http.response.body", "body": body})
+
+
@pytest.fixture
def cert_and_key_paths():
ca = trustme.CA()