Removed all uses of strftime() since it uses the localised version of the

week day names and month names and servers don't like that.
This commit is contained in:
Daniel Stenberg 2005-02-11 00:03:49 +00:00
parent d2485e4f20
commit e7cefd684b
8 changed files with 78 additions and 28 deletions

View File

@ -6,6 +6,10 @@
Changelog
Daniel (11 February 2005)
- Removed all uses of strftime() since it uses the localised version of the
week day names and month names and servers don't like that.
Daniel (10 February 2005)
- Now the test script disables valgrind-testing when the test suite runs if
libcurl is built shared. Otherwise valgrind only tests the shell that runs

View File

@ -22,10 +22,11 @@ This release includes the following bugfixes:
o inflate buffer usage bugfix
o better DICT protocol adherence
o disable valgrind-checking while testing if libcurl is built shared
o locale names in some date strings
Other curl-related news since the previous public release:
o
o pycurl 7.13.0: http://pycurl.sf.net/
This release would not have looked like this without help, code, reports and
advice from friends like these:

View File

@ -17,4 +17,4 @@ HHEADERS = arpa_telnet.h netrc.h file.h timeval.h base64.h hostip.h \
http_chunks.h strtok.h connect.h llist.h hash.h content_encoding.h \
share.h md5.h http_digest.h http_negotiate.h http_ntlm.h ca-bundle.h \
inet_pton.h strtoofft.h strerror.h inet_ntop.h curlx.h memory.h \
setup.h transfer.h select.h easyif.h multiif.h
setup.h transfer.h select.h easyif.h multiif.h parsedate.h

View File

@ -87,6 +87,7 @@
#include "transfer.h"
#include "url.h"
#include "memory.h"
#include "parsedate.h" /* for the week day and month names */
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@ -321,7 +322,6 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
if(result)
return result;
#ifdef HAVE_STRFTIME
if(fstated) {
struct tm *tm;
time_t clock = (time_t)statbuf.st_mtime;
@ -332,11 +332,17 @@ CURLcode Curl_file(struct connectdata *conn, bool *done)
tm = gmtime(&clock);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
strftime(buf, BUFSIZE-1, "Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n",
tm);
snprintf(buf, BUFSIZE-1,
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
tm->tm_mday,
Curl_month[tm->tm_mon],
tm->tm_year + 1900,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
}
#endif
return result;
}

View File

@ -94,6 +94,7 @@
#include "memory.h"
#include "inet_ntop.h"
#include "select.h"
#include "parsedate.h" /* for the week day and month names */
#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
#include "inet_ntoa_r.h"
@ -1738,7 +1739,6 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
/* If we asked for a time of the file and we actually got one as well,
we "emulate" a HTTP-style header in our output. */
#ifdef HAVE_STRFTIME
if(data->set.get_filetime && (data->info.filetime>=0) ) {
struct tm *tm;
time_t clock = (time_t)data->info.filetime;
@ -1749,13 +1749,19 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
tm = gmtime(&clock);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26" */
strftime(buf, BUFSIZE-1,
"Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n", tm);
snprintf(buf, BUFSIZE-1,
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
tm->tm_mday,
Curl_month[tm->tm_mon],
tm->tm_year + 1900,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
result = Curl_client_write(data, CLIENTWRITE_BOTH, buf, 0);
if(result)
return result;
}
#endif
}
break;
default:

View File

@ -95,6 +95,7 @@
#include "http.h"
#include "memory.h"
#include "select.h"
#include "parsedate.h" /* for the week day and month names */
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@ -1783,7 +1784,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#endif
if(data->set.timecondition) {
struct tm *thistime;
struct tm *tm;
/* Phil Karn (Fri, 13 Apr 2001) pointed out that the If-Modified-Since
* header family should have their times set in GMT as RFC2616 defines:
@ -1795,18 +1796,22 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#ifdef HAVE_GMTIME_R
/* thread-safe version */
struct tm keeptime;
thistime = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime);
tm = (struct tm *)gmtime_r(&data->set.timevalue, &keeptime);
#else
thistime = gmtime(&data->set.timevalue);
tm = gmtime(&data->set.timevalue);
#endif
#ifdef HAVE_STRFTIME
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
strftime(buf, BUFSIZE-1, "%a, %d %b %Y %H:%M:%S GMT", thistime);
#else
/* TODO: Right, we *could* write a replacement here */
strcpy(buf, "no strftime() support");
#endif
snprintf(buf, BUFSIZE-1,
"%s, %02d %s %4d %02d:%02d:%02d GMT",
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
tm->tm_mday,
Curl_month[tm->tm_mon],
tm->tm_year + 1900,
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
switch(data->set.timecondition) {
case CURL_TIMECOND_IFMODSINCE:
default:

View File

@ -86,14 +86,14 @@
static time_t Curl_parsedate(const char *date);
static const char * const wkday[] =
{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
const char * const Curl_wkday[] =
{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
static const char * const weekday[] =
{ "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday" };
static const char * const month[]=
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
{ "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday" };
const char * const Curl_month[]=
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
struct tzinfo {
const char *name;
@ -161,7 +161,7 @@ static int checkday(char *check, size_t len)
if(len > 3)
what = &weekday[0];
else
what = &wkday[0];
what = &Curl_wkday[0];
for(i=0; i<7; i++) {
if(curl_strequal(check, what[0])) {
found=TRUE;
@ -178,7 +178,7 @@ static int checkmonth(char *check)
const char * const *what;
bool found= FALSE;
what = &month[0];
what = &Curl_month[0];
for(i=0; i<12; i++) {
if(curl_strequal(check, what[0])) {
found=TRUE;

28
lib/parsedate.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef __PARSEDATE_H
#define __PARSEDATEL_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2004, 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 http://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.
*
* $Id$
***************************************************************************/
extern const char * const Curl_wkday[7];
extern const char * const Curl_month[12];
#endif