summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKwon-Young Choi <kwon-young.choi@hotmail.fr>2020-04-04 17:27:18 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-04-05 00:18:55 +0200
commiteb65e862cb9758b1f6e19442889e756e39fec85f (patch)
tree5542490a6407098bb0be2fa3a4a37cf9bbf5b6dc
parent23a870f2fd041278762ecf819cd1467019588c58 (diff)
downloadcurl-eb65e862cb9758b1f6e19442889e756e39fec85f.tar.gz
Do not write output file if server respond with http code 304
Using the --etag-compare option, we can ask the server to either send the file if it was updated or respond with a 304 response code to signify that the file did not change. This commit recognize this response code and avoid writing the output file, which avoid truncating a previously downloaded file. This fix issue #5181.
-rw-r--r--lib/getinfo.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 18274e964..84d9fc1c6 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -239,8 +239,11 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
*param_longp = data->info.conn_local_port;
break;
case CURLINFO_CONDITION_UNMET:
- /* return if the condition prevented the document to get transferred */
- *param_longp = data->info.timecond ? 1L : 0L;
+ if(data->info.httpcode == 304)
+ *param_longp = 1L;
+ else
+ /* return if the condition prevented the document to get transferred */
+ *param_longp = data->info.timecond ? 1L : 0L;
break;
case CURLINFO_RTSP_CLIENT_CSEQ:
*param_longp = data->state.rtsp_next_client_CSeq;