Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#9 Add CURLFORM_BUFFER and CURLFORM_BUFFERPTR support

Unstable_(example)
closed-accepted
Oleg Pudeyev
None
5
2013-12-15
2010-04-06
Kevin Ko
No

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

is used in combination with CURLFORM_BUFFER. The parameter is a long which gives the length of the buffer.

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.

Discussion

  • Kevin Ko
    Kevin Ko
    2010-04-06

    Patch for pycurl-7.19.0 that adds FORM_BUFFER and FORM_BUFFERPTR parameters for the HTTPPOST option

     
    Attachments
  • Kevin Ko
    Kevin Ko
    2010-04-06

    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

     
    • assigned_to: nobody --> zanee
    • status: open --> open-accepted
     
  • Oleg Pudeyev
    Oleg Pudeyev
    2013-12-15

    • status: open-accepted --> closed-accepted
    • assigned_to: Christopher Warner --> Oleg Pudeyev
    • Group: --> Unstable_(example)
     
  • Oleg Pudeyev
    Oleg Pudeyev
    2013-12-15

    Committed, thanks!