| 55 | ], |
| 56 | ) |
| 57 | def test_multipart_explicit_boundary(header: str) -> None: |
| 58 | client = httpx.Client(transport=httpx.MockTransport(echo_request_content)) |
| 59 | |
| 60 | files = {"file": io.BytesIO(b"<file content>")} |
| 61 | headers = {"content-type": header} |
| 62 | response = client.post("http://127.0.0.1:8000/", files=files, headers=headers) |
| 63 | boundary_bytes = b"+++" |
| 64 | |
| 65 | assert response.status_code == 200 |
| 66 | assert response.request.headers["Content-Type"] == header |
| 67 | assert response.content == b"".join( |
| 68 | [ |
| 69 | b"--" + boundary_bytes + b"\r\n", |
| 70 | b'Content-Disposition: form-data; name="file"; filename="upload"\r\n', |
| 71 | b"Content-Type: application/octet-stream\r\n", |
| 72 | b"\r\n", |
| 73 | b"<file content>\r\n", |
| 74 | b"--" + boundary_bytes + b"--\r\n", |
| 75 | ] |
| 76 | ) |
| 77 | |
| 78 | |
| 79 | @pytest.mark.parametrize( |