Browse Source

[multiple] more reuse of http_date_time_to_str()

master
Glenn Strauss 8 months ago
parent
commit
325d89b99f
  1. 2
      src/http-header-glue.c
  2. 7
      src/mod_expire.c
  3. 18
      src/mod_webdav.c

2
src/http-header-glue.c

@ -138,7 +138,7 @@ struct mtime_cache_type {
buffer str; /* buffer for string representation */
};
static struct mtime_cache_type mtime_cache[MTIME_CACHE_MAX];
static char mtime_cache_str[MTIME_CACHE_MAX][30];
static char mtime_cache_str[MTIME_CACHE_MAX][HTTP_DATE_SZ];
/* 30-chars for "%a, %d %b %Y %T GMT" */
void strftime_cache_reset(void) {

7
src/mod_expire.c

@ -4,6 +4,7 @@
#include "array.h"
#include "buffer.h"
#include "log.h"
#include "http_date.h"
#include "http_header.h"
#include "plugin.h"
@ -313,12 +314,12 @@ REQUEST_FUNC(mod_expire_handler) {
/* expires should be at least cur_ts */
if (expires < cur_ts) expires = cur_ts;
struct tm tm;
/* HTTP/1.0 */
vb = http_header_response_set_ptr(r, HTTP_HEADER_EXPIRES,
CONST_STR_LEN("Expires"));
buffer_append_strftime(vb, "%a, %d %b %Y %T GMT", gmtime_r(&expires,&tm));
buffer_commit(vb,
http_date_time_to_str(buffer_extend(vb, HTTP_DATE_SZ-1),
HTTP_DATE_SZ, expires));
/* HTTP/1.1 */
vb = http_header_response_set_ptr(r, HTTP_HEADER_CACHE_CONTROL,

18
src/mod_webdav.c

@ -3232,18 +3232,16 @@ webdav_propfind_live_props (const webdav_propfind_bufs * const restrict pb,
return -1; /* invalid; report 'not found' */
if (pnum != WEBDAV_PROP_ALL) return 0;/* found *//*(else fall through)*/
__attribute_fallthrough__
case WEBDAV_PROP_GETLASTMODIFIED: {
struct tm tm;
if (__builtin_expect( (NULL != gmtime_r(&pb->st.st_mtime, &tm)), 1)) {
buffer_append_string_len(b, CONST_STR_LEN(
"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"));
buffer_append_strftime(b, "%a, %d %b %Y %T GMT", &tm);
buffer_append_string_len(b, CONST_STR_LEN(
"</D:getlastmodified>"));
}
case WEBDAV_PROP_GETLASTMODIFIED:
buffer_append_string_len(b, CONST_STR_LEN(
"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"));
buffer_commit(b,
http_date_time_to_str(buffer_extend(b, HTTP_DATE_SZ-1),
HTTP_DATE_SZ, pb->st.st_mtime));
buffer_append_string_len(b, CONST_STR_LEN(
"</D:getlastmodified>"));
if (pnum != WEBDAV_PROP_ALL) return 0;/* found *//*(else fall through)*/
__attribute_fallthrough__
}
#if 0
#ifdef USE_LOCKS
case WEBDAV_PROP_LOCKDISCOVERY:

Loading…
Cancel
Save