http: don't clobber the receive buffer for timecond
This commit is contained in:
Родитель
f535f4f5fc
Коммит
87eb8d5b30
40
lib/http.c
40
lib/http.c
|
@ -1695,9 +1695,10 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
|
|||
Curl_send_buffer *req_buffer)
|
||||
{
|
||||
const struct tm *tm;
|
||||
char *buf = data->state.buffer;
|
||||
struct tm keeptime;
|
||||
CURLcode result;
|
||||
char datestr[80];
|
||||
const char *condp;
|
||||
|
||||
if(data->set.timecondition == CURL_TIMECOND_NONE)
|
||||
/* no condition was asked for */
|
||||
|
@ -1710,6 +1711,21 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
|
|||
}
|
||||
tm = &keeptime;
|
||||
|
||||
switch(data->set.timecondition) {
|
||||
default:
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
case CURL_TIMECOND_IFMODSINCE:
|
||||
condp = "If-Modified-Since";
|
||||
break;
|
||||
case CURL_TIMECOND_IFUNMODSINCE:
|
||||
condp = "If-Unmodified-Since";
|
||||
break;
|
||||
case CURL_TIMECOND_LASTMOD:
|
||||
condp = "Last-Modified";
|
||||
break;
|
||||
}
|
||||
|
||||
/* The If-Modified-Since header family should have their times set in
|
||||
* GMT as RFC2616 defines: "All HTTP date/time stamps MUST be
|
||||
* represented in Greenwich Mean Time (GMT), without exception. For the
|
||||
|
@ -1718,8 +1734,9 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
|
|||
*/
|
||||
|
||||
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
|
||||
snprintf(buf, BUFSIZE-1,
|
||||
"%s, %02d %s %4d %02d:%02d:%02d GMT",
|
||||
snprintf(datestr, sizeof(datestr),
|
||||
"%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
|
||||
condp,
|
||||
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
|
||||
tm->tm_mday,
|
||||
Curl_month[tm->tm_mon],
|
||||
|
@ -1728,22 +1745,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
|
|||
tm->tm_min,
|
||||
tm->tm_sec);
|
||||
|
||||
switch(data->set.timecondition) {
|
||||
default:
|
||||
break;
|
||||
case CURL_TIMECOND_IFMODSINCE:
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"If-Modified-Since: %s\r\n", buf);
|
||||
break;
|
||||
case CURL_TIMECOND_IFUNMODSINCE:
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"If-Unmodified-Since: %s\r\n", buf);
|
||||
break;
|
||||
case CURL_TIMECOND_LASTMOD:
|
||||
result = Curl_add_bufferf(req_buffer,
|
||||
"Last-Modified: %s\r\n", buf);
|
||||
break;
|
||||
}
|
||||
result = Curl_add_buffer(req_buffer, datestr, strlen(datestr));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче