cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Suggestion for curl_formadd()

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 29 Aug 2014 08:13:46 +0200 (CEST)

On Wed, 27 Aug 2014, Wolf Ihlenfeldt wrote:

> I am sending binary data without zero terminator bytes in fields, so I set
> CURLFORM_CONTENTSLENGTH. Sometimes this data can be of size 0 - I want to
> see an empty form field in the transmitted data in that case. However, in
> the current implementation, size 0 is also the value indicating an unset
> content length, so instead garbage is transmitted until the first random
> zero byte is hit. I am now checking for this condition beforehand and use an
> empty "" string in these cases and thus circumvent this problem. But I think
> for the sake of consistency and ease of use, it might be a good idea to
> change the internal "unset" default value to something like -1, so that you
> can explicitly set a zero field data length.

Thanks for this suggestions!

I agree that it would've been much more clever to use -1 or something for that
purpose, but as it is now this has been how this function has worked since
basically the dawn of man and if we were to change this now it is an ABI
change and quite likely there will be several applications out there that will
break in subtle ways.

I could possibly see us add a new option with that functionality and work on
deprecating the old, but I'm not convinced it is so important as the
work-around you figured out is also quite cheap and easy.

I've amended the man page now to detail this zero value functionality.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-08-29