This applies to pycurl 7.19.0 and adds support for libcurl's BUFFER and BUFFERPTR form parameters, which allow one to use a string as a POST parameter.
Example usage:
...
params = [
('x', (pycurl.FORM_BUFFER, "filename", pycurl.FORM_BUFFERPTR, "data"))
]
c = pycurl.Curl()
c.setopt(pycurl.HTTPPOST, params)
...
Excerpt from libcurl's API:
===
CURLFORM_BUFFERPTR
is used in combination with CURLFORM_BUFFER. The parameter is a pointer to the buffer to be uploaded. This buffer must not be freed until after curl_easy_cleanup(3) is called. You must also use CURLFORM_BUFFERLENGTH to set the number of bytes in the buffer.
CURLFORM_BUFFERLENGTH
Although the API docs say that the buffer should not be freed until curl_easy_cleanup() is called, I followed the liveness of CurlObject.httppost within pycurl.c, since the API makes identical assumptions.
Please direct comments to kevin.s.ko at gmail dot com.
Patch for pycurl-7.19.0 that adds FORM_BUFFER and FORM_BUFFERPTR parameters for the HTTPPOST option
Sorry, I should not have copied in CURLFORM_BUFFERLENGTH's description above, since that is handled internally. I meant to copy in CURLFORM_BUFFER:
CURLFORM_BUFFER
is used for custom file upload parts without use of CURLFORM_FILE. It tells libcurl that the file contents are already present in a buffer. The parameter is a string which provides the filename field in the content header.
I'll take a look at this patch a little later today or tomorrow
Committed, thanks!