cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multipart/related with libcurl 7.15.3 ? Any suggestions.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 22 Nov 2012 19:52:53 +0100 (CET)

On Thu, 22 Nov 2012, William Lear wrote:

> I am tasked with updating an existing embedded system to access a web
> service using SOAP with Attachments (multipart/related). The system is
> locked in to a prebuilt, ROM resident copy of libcurl 7.15.3, so I can't
> change it. There is insufficient memory to add a second updated copy along
> with the new code.
>
> I believe that changing the default "multipart/formdata" mime type may be
> sufficient to allow me to use CURLOPT_HTTPPOST, but have yet to find a way
> to do this.

Digging deep into the git history showed me this:

commit a88deadd6f85a6ac3b7f9d574bbb7eaab3115700
Author: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu Jul 27 22:35:09 2006 +0000

     Yves Lejeune fixed so that replacing Content-Type: when doing multipart
     formposts work exactly the way you want it (and the way you'd assume it
     works)

but...

$ git describe --contains a88deadd6f85a6a
curl-7_15_5~40

Meaning: you can use CURLOPT_HTTPHEADER to replace the Content-Type: with
CURLOPT_HTTPPOST the way you want it, in 7.15.5 and later!

> My next inclination would be to roll my own using curl_easy_send but, alas,
> that was not added until v7.18.2.

It sounds much better in that case to create the entire request body yourself
and send it with CURLOPT_POSTFIELDS and set the Content-Type: with
CURLOPT_HTTPHEADER. Should work just fine!

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-11-22