Pycurl equivalent to "curl --data-binary"

I would like to know the equivalent of this curl command in pycurl:

curl --data-binary @binary_data_file.bin 'http://server/myapp/method'

Note. The curl description above uses the POST method. I need to use this for compatibility with my server script.

+5
source share
2 answers

The library is requestsdesigned to store things like this simply:

import requests
r = requests.post('http://server/myapp/method', data={'aaa': 'bbb'})

Or depending on how the receiving party expects data:

import requests
r = requests.post('http://server/myapp/method',
    data=file('binary_data_file.bin','rb').read())
+5
source

From libcurl, setopt (...) try this option:

CURLOPT_POSTFIELDSIZE

, libcurl strlen() , . , , . -1, strlen() .

http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPOSTFIELDSIZE

+2

All Articles