cURL / Mailing Lists / curl-users / Single Mail

curl-users

zero bytes transfers and issue #382

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 21 Aug 2015 00:14:07 +0200 (CEST)

Hi friends!

In curl 7.42.0 we made curl capable of "transfering" zero byte files. It
basically means that it actually creates a zero byte file when you do

  $ curl [URL] -o output

... and the URL successfully returns a file with no content. This was one of
those silly things we've carried with us since forever and came out of the
fact that the code for -o that writes data only ever opened the file and wrote
something when data arrived and for a zero byte file of course no data came.

So, commit 261a0fedc brought this feature.

I've since realized that this introduced some interesting side-effects that
surprise users. Now suddenly all those users who got a zero byte file back and
were _happy_ with that gets an empty file that they don't need. Like when you
do:

  $ curl -H "If-None-Match: blala" [URL] -o output

... or other variations of HTTP that gets a HTTP error response back with no
body. This breaks scripts that previously could just check if 'output' was
created to see if curl actually got something or not.

So, I'm a bit stuck in a tough place. The previous behavior surprised a set of
users and so does the new. Further, I could possibly make non-2xx codes
not store zero byte files, but should -o behavior really care about HTTP
response codes and won't that just be even harder to explain and for users to
figure out?

I hesitate to even suggest it (because of the option bloat we already suffer
from), but does it need another command line option to get this solved for
both sets of use cases?

I could really use some fresh ideas and opinions. Especially if you use one of
these versions! Tell me what you think!

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-21