()
| 9 | |
| 10 | |
| 11 | def main(): |
| 12 | client = BlockingClient() |
| 13 | resp = client.post( |
| 14 | "https://httpbin.org/anything", |
| 15 | multipart=Multipart( |
| 16 | # Upload text data |
| 17 | Part(name="def", value="111", filename="def.txt", mime="text/plain"), |
| 18 | # Upload binary data |
| 19 | Part(name="abc", value=b"000", filename="abc.txt", mime="text/plain"), |
| 20 | # Unload file data |
| 21 | Part( |
| 22 | name="LICENSE", |
| 23 | value=Path("../../LICENSE"), |
| 24 | filename="LICENSE", |
| 25 | mime="text/plain", |
| 26 | ), |
| 27 | # Upload bytes stream file data |
| 28 | Part( |
| 29 | name="README", |
| 30 | value=file_to_bytes_stream("../../README.md"), |
| 31 | filename="README.md", |
| 32 | mime="text/plain", |
| 33 | ), |
| 34 | ), |
| 35 | ) |
| 36 | print("Status Code: ", resp.status_code) |
| 37 | print("Version: ", resp.version) |
| 38 | print("Response URL: ", resp.url) |
| 39 | print("Headers: ", resp.headers) |
| 40 | print("Cookies: ", resp.cookies) |
| 41 | print("Content-Length: ", resp.content_length) |
| 42 | print("Encoding: ", resp.encoding) |
| 43 | print("Remote Address: ", resp.remote_addr) |
| 44 | print("Text: ", resp.text()) |
| 45 | |
| 46 | |
| 47 | if __name__ == "__main__": |
no test coverage detected