Closed sxcisco closed 3 years ago
multipart_data
and body
of the post documentation on the readme.
- https://github.com/juancarlospaco/faster-than-requests/blob/master/examples/post_multipart.py
- https://github.com/juancarlospaco/faster-than-requests/blob/master/examples/post_file.py
- See
multipart_data
andbody
of the post documentation on the readme. `I would like to send a form similar to:
`POST /test.html HTTP/1.1 Host: example.org Content-Type: multipart/form-data;boundary="boundary"
--boundary Content-Disposition: form-data; name="field1"
value1 --boundary Content-Disposition: form-data; name="field2"; filename="example.txt"
value2`
Is it possible to use faster-than-requests for something like that?`
I do not understand what specifically you do not understand,
to send data on the body use the body
argument, theres example for body
on the repo,
to send data on the multipart data use the multipart_data
argument, theres example for multipart_data
on the repo,
to send content type use the http_headers
argument, all "data" is just a string, maybe practice on http://httpbin.org/post
I know how to use the multipart_data argument,
My problem is how to send the "data-binary" parameter with faster-than-requests
Content-Disposition: form-data; name="picture"; filename="123.jpg" Content-Type: image/jpeg
Can you help me give my example?
thank you.
import faster_than_requests
print(
faster_than_requests.post(
url = "http://httpbin.org/post",
body = "body data here",
http_headers = [("Content-Type", "text/plain"), ("dnt", "1")],
multipart_data = [("multi", "part"), ("key", "value")],
)
)
Plain text data is just string, binary data is just string too, HTTP over the wire is all just strings anyway.
If you want to send a file, just read it into a string variable, like mydata = open("file.txt").read()
.
If you like you can use bytes()
instead of string too.
For timeout, we have miliseconds precision, so it can be timeout = 5000
.
All arguments of all functions are simple primitive types, like string, bool, integer, etc.
We do not have any non-primitive binary blob thing, because no need for it and HTTP itself does not has it.
I dont know how to make it more explicit than that.
with requests
Is it possible to use faster-than-requests for something like that?