]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CURLINFO_CONDITION_UNMET: return true for 304 http status code
authorKwon-Young Choi <kwon-young.choi@hotmail.fr>
Sat, 4 Apr 2020 15:27:18 +0000 (17:27 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 5 Apr 2020 09:13:49 +0000 (11:13 +0200)
In libcurl, CURLINFO_CONDITION_UNMET is used to avoid writing to the
output file if the server did not transfered a file based on time
condition. In the same manner, getting a 304 HTTP response back from the
server, for example after passing a custom If-Match-* header, also
fulfill this condition.

Fixes #5181
Closes #5183

docs/libcurl/curl_easy_getinfo.3
docs/libcurl/opts/CURLINFO_CONDITION_UNMET.3
lib/getinfo.c

index c7b124a24579e98fd2b8f0b917aeea28381b5382..6471653583145bd82396270142ef1ced02d8880e 100644 (file)
@@ -210,7 +210,7 @@ TLS session info that can be used for further processing.  See
 \fICURLINFO_TLS_SESSION(3)\fP. Deprecated option, use
 \fICURLINFO_TLS_SSL_PTR(3)\fP instead!
 .IP CURLINFO_CONDITION_UNMET
-Whether or not a time conditional was met.
+Whether or not a time conditional was met or 304 HTTP response.
 See \fICURLINFO_CONDITION_UNMET(3)\fP
 .IP CURLINFO_RTSP_SESSION_ID
 RTSP session ID.
index 27488656e5290b3279a04f7b4370642204f0e208..78c28fa027663f865c2a0c98cdfcce65709611c4 100644 (file)
@@ -22,7 +22,7 @@
 .\"
 .TH CURLINFO_CONDITION_UNMET 3 "1 Sep 2015" "libcurl 7.44.0" "curl_easy_getinfo options"
 .SH NAME
-CURLINFO_CONDITION_UNMET \- get info on unmet time conditional
+CURLINFO_CONDITION_UNMET \- get info on unmet time conditional or 304 HTTP response.
 .SH SYNOPSIS
 #include <curl/curl.h>
 
@@ -32,7 +32,9 @@ Pass a pointer to a long to receive the number 1 if the condition provided in
 the previous request didn't match (see \fICURLOPT_TIMECONDITION(3)\fP). Alas,
 if this returns a 1 you know that the reason you didn't get data in return is
 because it didn't fulfill the condition. The long this argument points to will
-get a zero stored if the condition instead was met.
+get a zero stored if the condition instead was met. This can also return 1 if
+the server responded with a 304 HTTP status code, for example after sending a
+custom "If-Match-*" header.
 .SH PROTOCOLS
 HTTP and some
 .SH EXAMPLE
index 18274e964ea8f7cc4a5a6648ef096d635ec70a0c..84d9fc1c697ff398d91100b207b8438695c7c8b5 100644 (file)
@@ -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;