From 855887af7928d70a2938b7c9c750a0c237c47c15 Mon Sep 17 00:00:00 2001 From: Peter Simonyi Date: Wed, 10 Jul 2019 18:42:35 -0400 Subject: http: allow overriding timecond with custom header With CURLOPT_TIMECONDITION set, a header is automatically added (e.g. If-Modified-Since). Allow this to be replaced or suppressed with CURLOPT_HTTPHEADER. Fixes #4103 Closes #4109 --- lib/http.c | 14 ++++++++++---- lib/http.h | 2 +- lib/rtsp.c | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/http.c b/lib/http.c index ccf64a270..9fbd7201e 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1881,9 +1881,10 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn, } #ifndef CURL_DISABLE_PARSEDATE -CURLcode Curl_add_timecondition(struct Curl_easy *data, +CURLcode Curl_add_timecondition(const struct connectdata *conn, Curl_send_buffer *req_buffer) { + struct Curl_easy *data = conn->data; const struct tm *tm; struct tm keeptime; CURLcode result; @@ -1916,6 +1917,11 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data, break; } + if(Curl_checkheaders(conn, condp)) { + /* A custom header was specified; it will be sent instead. */ + return CURLE_OK; + } + /* The If-Modified-Since header family should have their times set in * GMT as RFC2616 defines: "All HTTP date/time stamps MUST be * represented in Greenwich Mean Time (GMT), without exception. For the @@ -1941,10 +1947,10 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data, } #else /* disabled */ -CURLcode Curl_add_timecondition(struct Curl_easy *data, +CURLcode Curl_add_timecondition(const struct connectdata *conn, Curl_send_buffer *req_buffer) { - (void)data; + (void)conn; (void)req_buffer; return CURLE_OK; } @@ -2683,7 +2689,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done) } #endif - result = Curl_add_timecondition(data, req_buffer); + result = Curl_add_timecondition(conn, req_buffer); if(result) return result; diff --git a/lib/http.h b/lib/http.h index 5af80e75d..72161f6b0 100644 --- a/lib/http.h +++ b/lib/http.h @@ -69,7 +69,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer **inp, size_t included_body_bytes, int socketindex); -CURLcode Curl_add_timecondition(struct Curl_easy *data, +CURLcode Curl_add_timecondition(const struct connectdata *conn, Curl_send_buffer *buf); CURLcode Curl_add_custom_headers(struct connectdata *conn, bool is_connect, diff --git a/lib/rtsp.c b/lib/rtsp.c index 74cf23244..25e194a23 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -491,7 +491,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done) return result; if((rtspreq == RTSPREQ_SETUP) || (rtspreq == RTSPREQ_DESCRIBE)) { - result = Curl_add_timecondition(data, req_buffer); + result = Curl_add_timecondition(conn, req_buffer); if(result) return result; } -- cgit v1.2.3