Browse Source

[core] http_date_time_append() convenience macro

append IMF-fixdate time string to (buffer *)
master
Glenn Strauss 5 months ago
parent
commit
3a568c639c
  1. 7
      src/http_date.h
  2. 4
      src/mod_expire.c
  3. 4
      src/mod_webdav.c

7
src/http_date.h

@ -22,6 +22,13 @@ uint32_t http_date_time_to_str (char *s, size_t sz, time_t t);
int http_date_if_modified_since (const char *ifmod, uint32_t ifmodlen, time_t lmtime);
/*(convenience macro to append IMF-fixdate to (buffer *))*/
#define http_date_time_append(b, t) \
do { \
if (!http_date_time_to_str(buffer_extend((b), HTTP_DATE_SZ-1), \
HTTP_DATE_SZ, (t))) \
buffer_truncate((b), (b)->used - HTTP_DATE_SZ); /*(truncate if err)*/ \
} while (0)
#ifdef __cplusplus
}

4
src/mod_expire.c

@ -282,9 +282,7 @@ mod_expire_set_header (request_st * const r, const time_t * const off)
else { /* HTTP/1.0 */
vb = http_header_response_set_ptr(r, HTTP_HEADER_EXPIRES,
CONST_STR_LEN("Expires"));
if (!http_date_time_to_str(buffer_extend(vb, HTTP_DATE_SZ-1),
HTTP_DATE_SZ, expires))
buffer_truncate(vb, buffer_clen(vb)+1-HTTP_DATE_SZ);
http_date_time_append(vb, expires);
}
return HANDLER_GO_ON;

4
src/mod_webdav.c

@ -3234,9 +3234,7 @@ webdav_propfind_live_props (const webdav_propfind_bufs * const restrict pb,
case WEBDAV_PROP_GETLASTMODIFIED:
buffer_append_string_len(b, CONST_STR_LEN(
"<D:getlastmodified ns0:dt=\"dateTime.rfc1123\">"));
if (!http_date_time_to_str(buffer_extend(b, HTTP_DATE_SZ-1),
HTTP_DATE_SZ, pb->st.st_mtime))
buffer_truncate(b, buffer_clen(b)+1-HTTP_DATE_SZ);
http_date_time_append(b, 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)*/

Loading…
Cancel
Save