Thread: libcURL POST items

  1. #1
    Registered User
    Join Date
    Jul 2004

    libcURL POST items

    I'm using libcurl to access an HTTPS "page" (the output is binary which the app understands rather than a page as such). The app also sends binary data to the page (a PHP script) via post. This all works fine (using curl_formadd with CURLFORM_PTRCONTENTS and CONTENTSLENGTH), except when the binary data to be transmitted contains NULL bytes. Even with the length specified, CURL is treating these as string delimiters. Is there a way to override this? since I can't even change all 0x00 to 0xFF or any similar substitution as any 8bit value is valid for some of the bytes. I realise that inserting escape values etc. would be an option, but am keen to avoid this for efficiency reasons.

    Thanks in advance,


  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Banks of the River Styx
    How do you call curl_formadd() (could we see the relevant code...?) Also, is the length you're passing to cURL correct (double check it)?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User
    Join Date
    Jul 2004
    curl_formadd(&lPOST, &lPOSTLast, CURLFORM_COPYNAME, "Request", CURLFORM_COPYCONTENTS, lCurrentRequest->Data,
    Sorry, for delay. That's the code, the Data and Length variables are definately set correctly. I've also tried using PTRCONTENTS, but no different. I've now resorted to passing a second request which is an array of "unsigned char" indices (+1 to allow first byte to be NULL) for NULL bytes, and then setting them to 0x01. This works, but limits this request to being 255 bytes long (since making the array into shorts or above would in itself create NULL bytes).



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create new combo boxes based on items selected in preview combo box
    By RealityFusion in forum Windows Programming
    Replies: 2
    Last Post: 01-10-2007, 09:50 AM
  2. Post your Best Text Adventure
    By Joe100 in forum Game Programming
    Replies: 3
    Last Post: 08-15-2003, 05:47 PM
  3. Auto POST
    By vasanth in forum A Brief History of
    Replies: 10
    Last Post: 06-07-2003, 10:42 AM
  4. scan multiple items in multidimensional array
    By requiem in forum C Programming
    Replies: 1
    Last Post: 04-17-2003, 03:02 PM
  5. CListView & Appending Items :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-28-2002, 11:37 AM