}
}
- 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);
/* 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;
}
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;
}
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)
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;