Speed – libcurl is very fast and PycURL, being a thin wrapper above libcurl, is very fast as well. PycURL was benchmarkedto be several times faster than requests.
Features including multiple protocol support, SSL, authentication and proxy options. PycURL supports most of libcurl’s callbacks.
Multi and share interfaces.
Sockets used for network operations, permitting integration of PycURL into the application’s I/O loop (e.g., using Tornado).
Python 2.6, 2.7 or 3.1 through 3.6.
libcurl 7.19.0 or better.
Download source and binary distributions from PyPI or Bintray. Binary wheels are now available for 32 and 64 bit Windows versions.
Please see INSTALL.rst for installation instructions. If installing from a Git checkout, please follow instruction in the Git Checkout section of INSTALL.rst.
def do_http_request(method, url, post_data=”, upload_file=None):
ch = pycurl.Curl()
buf = StringIO.StringIO()
if upload_file != None:
ch.setopt(ch.HTTPPOST, [(‘file’, (ch.FORM_FILE, upload_file[‘file_path’], \
if method == self.METHOD_POST:
content = buf.getvalue()
The above code is written in a library with pycurl http request to call a generic function.
upload_file is a dict type requires two key, file_path (specify the file path to upload) and file_name (file name specified after the upload).
ch.FORM_FILE : Specifies the path to the file you want to upload
ch.FORM_FILENAME : Specifies the name of the file you want to upload
The post [Python] upload file using PycURL appeared first on Penetration Testing.