On Tue, 4 Apr 2017, Reese Grimsley wrote:

So since I am going to be using the same host, it will use the same physical connection, and it will be able to send multiple independent transfer?

As I already answered this I'm not sure what else I'm going to reply when you ask again without adding any more specific details to the question to help me give a more specific answer. So: yes, maybe.

I am confused on how to format a multipart POST request. I notice that when I set the content-type to multipart/form-data, it includes its own (randomly generated?) boundary term.

It does, yes. But you're also setting that content-type header in vein since libcurl will set that itself for multipart formposts.

Can this boundary term by easily changed?

No, it can't be changed at all actually, if you want to use libcurl's formposting functions.

If you think you need to set that string yourself you need to construct the entire post "manually" and not use libcurl's formposting functions and instead just send a normal "raw" posted crafted as you see fit, with the boundary strings, separators, headers and all.

My main question though is how to set the fields that look to be very similar to headers underneath the --"boundary" line, and then include the actual message data below that.

They're not only similar to headers, they *are* headers. Each individual section in a multipart post has its own set of headers. With libcurl you set your headers with curl_formadd()'s CURLFORM_CONTENTHEADER option.

Should these fields be defined by some setopt function, or are they a part of the message?

libcurl will set a few when you use curl_formadd() so that each section becomes a valid and working part as defined in the spec, but you can extend that set if you want others there.

It is supposed to look like what I have included in the last few lines of this message.

The Content-Disposition: is automatically set by libcurl (as you can see when you check what libcurl sends in a formpost) and the Content-Type: header is set for a few files (based on the extension) but you can also set that with CURLFORM_CONTENTTYPE.

Following these "headers" (are they considered headers, or is there a
better terminology?) would be a JSON formatted string of data, followed by
a --boundary-- line.

That data is the contents: CURLFORM_COPYCONTENTS.

All this is explained and there's an example, in the man page for curl_formadd: https://curl.haxx.se/libcurl/c/curl_formadd.html

--

 / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to