curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: CURLOPT_POST with no CURLOPT_POSTFIELDS

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 6 Mar 2020 22:00:49 +0100 (CET)

On Fri, 6 Mar 2020, Jason Proctor via curl-library wrote:

> Looking at the test case I think the issue is that I set CURLOPT_POST and
> provide neither CURLOPT_POSTFIELDS nor a read function. If the API contract
> says I have to do one or the other, fair enough - but should Curl survive if
> I don't?

Okay but as a POST request implies a request body, where do you provide said
body?

Without CURLOPT_POSTFIELDS (and *with* CURLOPT_POST set), libcurl only offers
one other way to provide the request body and that is the read callback. If
you don't set it, libcurl has a default read function that does an fread() by
stdin by default.

What did you expect would happen? A zero byte body?

In my mind, CURLOPT_POST explains that you *either* use CURLOPT_POSTFIELDS or
a read callback and that there's no third option, but I'm certainly open for
that we need to extend or clarify the docs somewhere!

-- 
  / daniel.haxx.se | Commercial curl support up to 24x7 is available!
                   | 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 2020-03-06