| 421 | |
| 422 | |
| 423 | def test_multipart_rewinds_files(): |
| 424 | with tempfile.TemporaryFile() as upload: |
| 425 | upload.write(b"Hello, world!") |
| 426 | |
| 427 | transport = httpx.MockTransport(echo_request_content) |
| 428 | client = httpx.Client(transport=transport) |
| 429 | |
| 430 | files = {"file": upload} |
| 431 | response = client.post("http://127.0.0.1:8000/", files=files) |
| 432 | assert response.status_code == 200 |
| 433 | assert b"\r\nHello, world!\r\n" in response.content |
| 434 | |
| 435 | # POSTing the same file instance a second time should have the same content. |
| 436 | files = {"file": upload} |
| 437 | response = client.post("http://127.0.0.1:8000/", files=files) |
| 438 | assert response.status_code == 200 |
| 439 | assert b"\r\nHello, world!\r\n" in response.content |
| 440 | |
| 441 | |
| 442 | class TestHeaderParamHTML5Formatting: |