summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2015-03-30 13:56:30 +0200
committerKamil Dudka <kdudka@redhat.com>2015-04-08 09:43:08 +0200
commit261a0fedcf1545440190965311a1554d7695b6c0 (patch)
treefc1b18059e541956123dcc96b4fd3e46610d25db
parentf251417d85d232605ca86e9562a64500c67ccdee (diff)
downloadgnurl-261a0fedcf1545440190965311a1554d7695b6c0.tar.gz
gnurl-261a0fedcf1545440190965311a1554d7695b6c0.tar.bz2
gnurl-261a0fedcf1545440190965311a1554d7695b6c0.zip
src/tool_operate: create output file on successful download
... of an empty file Bug: https://github.com/bagder/curl/issues/183
-rw-r--r--RELEASE-NOTES2
-rw-r--r--src/tool_cb_wrt.h3
-rw-r--r--src/tool_operate.c7
3 files changed, 12 insertions, 0 deletions
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index c4aafacfd..60083e222 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -14,6 +14,7 @@ This release includes the following changes:
o curl: add --false-start option
o add CURLOPT_PATH_AS_IS
o curl: add --path-as-is option
+ o curl: create output file on successful download of an empty file [21]
This release includes the following bugfixes:
@@ -154,3 +155,4 @@ References to bug reports and discussions on issues:
[18] = http://curl.haxx.se/bug/view.cgi?id=1486
[19] = https://github.com/bagder/curl/issues/195
[20] = https://github.com/bagder/curl/issues/192
+ [21] = https://github.com/bagder/curl/issues/183
diff --git a/src/tool_cb_wrt.h b/src/tool_cb_wrt.h
index 380d8dd6a..ecbefa808 100644
--- a/src/tool_cb_wrt.h
+++ b/src/tool_cb_wrt.h
@@ -29,5 +29,8 @@
size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata);
+/* create a local file for writing, return TRUE on success */
+bool tool_create_output_file(struct OutStruct *outs);
+
#endif /* HEADER_CURL_TOOL_CB_WRT_H */
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 01a61f9a7..771e42da6 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1388,6 +1388,13 @@ static CURLcode operate_do(struct GlobalConfig *global,
#endif
result = curl_easy_perform(curl);
+ if(!result && !outs.stream && !outs.bytes
+ /* we have received no data despite the transfer was successful
+ ==> force cration of an empty output file (if an output file
+ was specified) */
+ && !tool_create_output_file(&outs))
+ result = CURLE_WRITE_ERROR;
+
if(outs.is_cd_filename && outs.stream && !global->mute &&
outs.filename)
printf("curl: Saved to filename '%s'\n", outs.filename);