Re: debug CURLOPT_POSTFIELDS url?
Date: Tue, 29 Oct 2019 12:41:49 +1100
hi,
So another newbie question just to confirm: after reading the docs
more one doesnt actually send files, even in the case below its
actually always buffer?
curl_mime *mime;
curl_mimepart *part;
// create a mime handle
mime = curl_mime_init(easy);
// add a part
part = curl_mime_addpart(mime);
// send data from this file
curl_mime_filedata(part, "image.png");
// set name
curl_mime_name(part, "data");
On Mon, Oct 28, 2019 at 8:14 PM ka sc <kabischmid_at_gmail.com> wrote:
>
> hi,
> Sorry, I see this has been asked a lot before.
> So that means I should read the data into a buffer and pass a pointer like
> const char *dataChar = data.c_str();
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataChar);
> If somebody remembers an example out there thanks for saving the google
>
> On Mon, Oct 28, 2019 at 7:54 PM Daniel Stenberg <daniel_at_haxx.se> wrote:
> >
> > On Mon, 28 Oct 2019, ka sc via curl-library wrote:
> >
> > > curl -XPOST localhost:4001/db/load -H "Content-type: text/plain"
> > > --data-binary @"data/input.dump" --libcurl code.c
> >
> > 1. You don't want "-XPOST" when you use -d or a --data* flag. Remove it.
> >
> > 2. "--data-binary @"data/input.dump" is reading the file into a buffer and
> > uses CURLOPT_POSTFIELDS to send it as a POST.
> >
> > > curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1);
> >
> > This would make it use the read callback (or stdin) instead to get the data,
> > which you of course can opt to do.
> >
> > --
> >
> > / daniel.haxx.se | Get the best commercial curl support there is - from me
> > | Private help, bug fixes, support, ports, new features
> > | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-10-29