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