Skip to content

Commit

Permalink
Merge 0c66a5b into 9a230ba
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Jan 25, 2018
2 parents 9a230ba + 0c66a5b commit d4aa773
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 11 deletions.
11 changes: 7 additions & 4 deletions docs/libcurl/opts/CURLINFO_FILETIME.3
Expand Up @@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -34,9 +34,12 @@ Pass a pointer to a long to receive the remote time of the retrieved document
hide it or the server doesn't support the command that tells document time
etc) and the time of the document is unknown.

Note that you must tell the server to collect this information before the
transfer is made, by using the \fICURLOPT_FILETIME(3)\fP option to
\fIcurl_easy_setopt(3)\fP or you will unconditionally get a -1 back.
You must tell libcurl to collect this information before the transfer is made,
by using the \fICURLOPT_FILETIME(3)\fP option to \fIcurl_easy_setopt(3)\fP or
you will unconditionally get a -1 back.

Consider using \fICURLINFO_FILETIME_T(3)\fP to be able to extract dates beyond
the year 2038 on systems using 32 bit longs.
.SH PROTOCOLS
HTTP(S), FTP(S), SFTP
.SH EXAMPLE
Expand Down
71 changes: 71 additions & 0 deletions docs/libcurl/opts/CURLINFO_FILETIME_T.3
@@ -0,0 +1,71 @@
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
.\" * are also available at https://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" **************************************************************************
.\"
.TH CURLINFO_FILETIME 3 "25 Jan 2018" "libcurl 7.59.0" "curl_easy_getinfo options"
.SH NAME
CURLINFO_FILETIME_T \- get the remote time of the retrieved document
.SH SYNOPSIS
#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T, curl_off_t *timep);
.SH DESCRIPTION
Pass a pointer to a curl_off_t to receive the remote time of the retrieved
document (in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If
you get -1, it can be because of many reasons (it might be unknown, the server
might hide it or the server doesn't support the command that tells document
time etc) and the time of the document is unknown.

You must ask libcurl to collect this information before the transfer is made,
by using the \fICURLOPT_FILETIME(3)\fP option to \fIcurl_easy_setopt(3)\fP or
you will unconditionally get a -1 back.

This option is an alternative to \fICURLINFO_FILETIME(3)\fP to allow systems
with 32 bit long variables to extract dates outside of the 32bit timestamp
range.
.SH PROTOCOLS
HTTP(S), FTP(S), SFTP
.SH EXAMPLE
.nf
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
/* Ask for filetime */
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
res = curl_easy_perform(curl);
if(CURLE_OK == res) {
curl_off_t filetime;
res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
if((CURLE_OK == res) && (filetime >= 0)) {
time_t file_time = (time_t)filetime;
printf("filetime %s: %s", filename, ctime(&file_time));
}
}
/* always cleanup */
curl_easy_cleanup(curl);
}
.fi
.SH AVAILABILITY
Added in 7.59.0
.SH RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
.SH "SEE ALSO"
.BR curl_easy_getinfo "(3), " curl_easy_setopt "(3), "
5 changes: 4 additions & 1 deletion docs/libcurl/opts/CURLOPT_TIMEVALUE.3
Expand Up @@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
Expand All @@ -31,6 +31,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE, long val);
Pass a long \fIval\fP as parameter. This should be the time counted as seconds
since 1 Jan 1970, and the time will be used in a condition as specified with
\fICURLOPT_TIMECONDITION(3)\fP.

On systems with 32 bit 'long' variables, this option cannot set dates beyond
the year 2038. Consider \fICURLOPT_TIMEVALUE_LARGE(3)\fP instead.
.SH DEFAULT
0
.SH PROTOCOLS
Expand Down
64 changes: 64 additions & 0 deletions docs/libcurl/opts/CURLOPT_TIMEVALUE_LARGE.3
@@ -0,0 +1,64 @@
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
.\" * are also available at https://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" **************************************************************************
.\"
.TH CURLOPT_TIMEVALUE_LARGE 3 "25 Jan 2018" "libcurl 7.59.0" "curl_easy_setopt options"
.SH NAME
CURLOPT_TIMEVALUE_LARGE \- set time value for conditional
.SH SYNOPSIS
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEVALUE_LARGE, curl_off_t val);
.SH DESCRIPTION
Pass a curl_off_t \fIval\fP as parameter. This should be the time counted as
seconds since 1 Jan 1970, and the time will be used in a condition as
specified with \fICURLOPT_TIMECONDITION(3)\fP.

The difference between this option and \fICURLOPT_TIMEVALUE(3)\fP is the type
of the argument. On systems where 'long' is only 32 bit wide, this option has
to be used to set dates beyond the year 2038.
.SH DEFAULT
0
.SH PROTOCOLS
HTTP, FTP, RTSP, and FILE
.SH EXAMPLE
.nf
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");

/* January 1, 2020 is 1577833200 */
curl_easy_setopt(curl, CURLOPT_TIMEVALUE_LARGE, (curl_off_t)1577833200);

/* If-Modified-Since the above time stamp */
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);

/* Perform the request */
curl_easy_perform(curl);
}
.fi
.SH AVAILABILITY
Added in 7.59.0.
.SH RETURN VALUE
Returns CURLE_OK
.SH "SEE ALSO"
.BR CURLOPT_TIMECONDITION "(3), "
.BR CURLOPT_TIMEVALUE_LARGE "(3), "
2 changes: 2 additions & 0 deletions docs/libcurl/opts/Makefile.inc
Expand Up @@ -14,6 +14,7 @@ man_MANS = \
CURLINFO_COOKIELIST.3 \
CURLINFO_EFFECTIVE_URL.3 \
CURLINFO_FILETIME.3 \
CURLINFO_FILETIME_T.3 \
CURLINFO_FTP_ENTRY_PATH.3 \
CURLINFO_HEADER_SIZE.3 \
CURLINFO_HTTPAUTH_AVAIL.3 \
Expand Down Expand Up @@ -301,6 +302,7 @@ man_MANS = \
CURLOPT_TIMEOUT.3 \
CURLOPT_TIMEOUT_MS.3 \
CURLOPT_TIMEVALUE.3 \
CURLOPT_TIMEVALUE_LARGE.3 \
CURLOPT_TLSAUTH_PASSWORD.3 \
CURLOPT_TLSAUTH_TYPE.3 \
CURLOPT_TLSAUTH_USERNAME.3 \
Expand Down
2 changes: 2 additions & 0 deletions docs/libcurl/symbols-in-versions
Expand Up @@ -220,6 +220,7 @@ CURLINFO_DOUBLE 7.4.1
CURLINFO_EFFECTIVE_URL 7.4
CURLINFO_END 7.9.6
CURLINFO_FILETIME 7.5
CURLINFO_FILETIME_T 7.59.0
CURLINFO_FTP_ENTRY_PATH 7.15.4
CURLINFO_HEADER_IN 7.9.6
CURLINFO_HEADER_OUT 7.9.6
Expand Down Expand Up @@ -587,6 +588,7 @@ CURLOPT_TIMECONDITION 7.1
CURLOPT_TIMEOUT 7.1
CURLOPT_TIMEOUT_MS 7.16.2
CURLOPT_TIMEVALUE 7.1
CURLOPT_TIMEVALUE_LARGE 7.59.0
CURLOPT_TLSAUTH_PASSWORD 7.21.4
CURLOPT_TLSAUTH_TYPE 7.21.4
CURLOPT_TLSAUTH_USERNAME 7.21.4
Expand Down
7 changes: 6 additions & 1 deletion include/curl/curl.h
Expand Up @@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -1819,6 +1819,10 @@ typedef enum {
/* Post MIME data. */
CINIT(MIMEPOST, OBJECTPOINT, 269),

/* Time to use with the CURLOPT_TIMECONDITION. Specified in number of
seconds since 1 Jan 1970. */
CINIT(TIMEVALUE_LARGE, OFF_T, 270),

CURLOPT_LASTENTRY /* the last unused */
} CURLoption;

Expand Down Expand Up @@ -2459,6 +2463,7 @@ typedef enum {
CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
CURLINFO_FILETIME = CURLINFO_LONG + 14,
CURLINFO_FILETIME_T = CURLINFO_OFF_T + 14,
CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
CURLINFO_CONTENT_LENGTH_DOWNLOAD_T = CURLINFO_OFF_T + 15,
CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
Expand Down
5 changes: 4 additions & 1 deletion lib/getinfo.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -253,6 +253,9 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
curl_off_t *param_offt)
{
switch(info) {
case CURLINFO_FILETIME_T:
*param_offt = (curl_off_t)data->info.filetime;
break;
case CURLINFO_SIZE_UPLOAD_T:
*param_offt = data->progress.uploaded;
break;
Expand Down
8 changes: 8 additions & 0 deletions lib/setopt.c
Expand Up @@ -361,6 +361,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
data->set.timevalue = (time_t)va_arg(param, long);
break;

case CURLOPT_TIMEVALUE_LARGE:
/*
* This is the value to compare with the remote document with the
* method set with CURLOPT_TIMECONDITION
*/
data->set.timevalue = (time_t)va_arg(param, curl_off_t);
break;

case CURLOPT_SSLVERSION:
case CURLOPT_PROXY_SSLVERSION:
/*
Expand Down
6 changes: 2 additions & 4 deletions lib/urldata.h
Expand Up @@ -1024,10 +1024,8 @@ struct PureInfo {
int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */
int httpproxycode; /* response code from proxy when received separate */
int httpversion; /* the http version number X.Y = X*10+Y */
long filetime; /* If requested, this is might get set. Set to -1 if the time
was unretrievable. We cannot have this of type time_t,
since time_t is unsigned on several platforms such as
OpenVMS. */
time_t filetime; /* If requested, this is might get set. Set to -1 if the
time was unretrievable. */
bool timecond; /* set to TRUE if the time condition didn't match, which
thus made the document NOT get fetched */
long header_size; /* size of read header(s) in bytes */
Expand Down

0 comments on commit d4aa773

Please sign in to comment.