- if(options->check_file_server_time && time_condition != 0) {
- /* if file exists, check against server if file is recent enough */
- curl_easy_setopt ( curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
- curl_easy_setopt ( curl, CURLOPT_TIMEVALUE, time_condition);
+ if (file_options != NULL) {
+ if(options->check_file_server_time && file_options->time_condition != 0) {
+ /* if file exists, check against server if file is recent enough */
+ curl_easy_setopt ( curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+ curl_easy_setopt ( curl, CURLOPT_TIMEVALUE, file_options->time_condition);
+ }
+ if (options->use_etag) {
+ if (file_options->etag != NULL) {
+ /* add an header on the HTTP request */
+ char str[60];
+ g_snprintf(str, 60, "If-None-Match: %s", file_options->etag);
+ curl_send_headers = curl_slist_append(curl_send_headers, str);
+ curl_easy_setopt ( curl, CURLOPT_HTTPHEADER , curl_send_headers);
+ }
+ /* store the new etag from the server in an option value */
+ curl_easy_setopt ( curl, CURLOPT_WRITEHEADER, &(file_options->new_etag));
+ curl_easy_setopt ( curl, CURLOPT_HEADERFUNCTION, curl_get_etag_func);
+ }