aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-11-22 13:50:17 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-11-22 13:50:17 +0000
commitb5739b3a97318ee52b5069b305e43ea972621b0c (patch)
tree3aaee27a94da752bd37270ccfc04d78a34e58010
parent86d4488cc7e8ccd3406b121066f8f6c8b7c7660d (diff)
document time fixes
-rw-r--r--lib/ftp.c25
-rw-r--r--lib/getinfo.c3
-rw-r--r--lib/highlevel.c2
-rw-r--r--lib/url.c3
4 files changed, 29 insertions, 4 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index eb3f58453..88601f2ea 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -659,9 +659,9 @@ CURLcode _ftp(struct connectdata *conn)
}
}
- if(data->bits.get_filetime) {
+ if(data->bits.get_filetime && ftp->file) {
/* we have requested to get the modified-time of the file, this is yet
- again a grey area the MDTM is not kosher RFC959 */
+ again a grey area as the MDTM is not kosher RFC959 */
ftpsendf(data->firstsocket, conn, "MDTM %s", ftp->file);
nread = GetLastResponse(data->firstsocket, buf, conn, &ftpcode);
@@ -725,10 +725,29 @@ CURLcode _ftp(struct connectdata *conn)
/* get the size from the ascii string: */
filesize = atoi(buf+4);
- sprintf(buf, "Content-Length: %d\n", filesize);
+ sprintf(buf, "Content-Length: %d\r\n", filesize);
result = client_write(data, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;
+
+#ifdef HAVE_STRFTIME
+ if(data->bits.get_filetime && data->progress.filetime) {
+ struct tm *tm;
+#ifdef HAVE_LOCALTIME_R
+ struct tm buffer;
+ tm = (struct tm *)localtime_r(&data->progress.filetime, &buffer);
+#else
+ tm = localtime(&data->progress.filetime);
+#endif
+ /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
+ strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S %Z\r\n",
+ tm);
+ result = client_write(data, CLIENTWRITE_BOTH, buf, 0);
+ if(result)
+ return result;
+ }
+#endif
+
return CURLE_OK;
}
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 786692c89..1b3e59767 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -84,6 +84,9 @@ CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...)
case CURLINFO_HTTP_CODE:
*param_longp = data->progress.httpcode;
break;
+ case CURLINFO_FILETIME:
+ *param_longp = data->progress.filetime;
+ break;
case CURLINFO_HEADER_SIZE:
*param_longp = data->header_size;
break;
diff --git a/lib/highlevel.c b/lib/highlevel.c
index e77c7eba4..dc7acc130 100644
--- a/lib/highlevel.c
+++ b/lib/highlevel.c
@@ -395,7 +395,7 @@ _Transfer(struct connectdata *c_conn)
}
else if(strnequal("Last-Modified:", p,
strlen("Last-Modified:")) &&
- data->timecondition) {
+ (data->timecondition || data->bits.get_filetime) ) {
time_t secs=time(NULL);
timeofdoc = curl_getdate(p+strlen("Last-Modified:"), &secs);
if(data->bits.get_filetime)
diff --git a/lib/url.c b/lib/url.c
index 878aee1f6..9522034f0 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -365,6 +365,9 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
case CURLOPT_POST:
data->bits.http_post = va_arg(param, long)?TRUE:FALSE;
break;
+ case CURLOPT_FILETIME:
+ data->bits.get_filetime = va_arg(param, long)?TRUE:FALSE;
+ break;
case CURLOPT_FTPLISTONLY:
data->bits.ftp_list_only = va_arg(param, long)?TRUE:FALSE;
break;