Changeset c3353ae5 in rtems for cpukit/mghttpd/mongoose.c


Ignore:
Timestamp:
Mar 8, 2018, 4:12:30 AM (3 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11
Children:
d4165e71
Parents:
7093cb5e
git-author:
Chris Johns <chrisj@…> (03/08/18 04:12:30)
git-committer:
Chris Johns <chrisj@…> (03/08/18 04:34:15)
Message:

cpukit/mttpd: Add a callback to generate a per file HTTP etag.

Closes #3324

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/mghttpd/mongoose.c

    r7093cb5e rc3353ae5  
    29902990}
    29912991
    2992 static void construct_etag(char *buf, size_t buf_len,
     2992static void construct_etag(const struct mg_connection *conn, const char *path,
     2993                           char *buf, size_t buf_len,
    29932994                           const struct file *filep) {
    2994   snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"",
    2995            (unsigned long) filep->modification_time, filep->size);
     2995  if (conn->ctx->callbacks.http_etag != NULL &&
     2996      conn->ctx->callbacks.http_etag(conn, path, buf, buf_len)) {
     2997  }
     2998  else {
     2999    snprintf(buf, buf_len, "\"%lx.%" INT64_FMT "\"",
     3000             (unsigned long) filep->modification_time, filep->size);
     3001  }
    29963002}
    29973003
     
    30623068  gmt_time_string(date, sizeof(date), &curtime);
    30633069  gmt_time_string(lm, sizeof(lm), &filep->modification_time);
    3064   construct_etag(etag, sizeof(etag), filep);
     3070  construct_etag(conn, path, etag, sizeof(etag), filep);
    30653071
    30663072  (void) mg_printf(conn,
     
    32223228// Return True if we should reply 304 Not Modified.
    32233229static int is_not_modified(const struct mg_connection *conn,
     3230                           const char *path,
    32243231                           const struct file *filep) {
    32253232  char etag[64];
    32263233  const char *ims = mg_get_header(conn, "If-Modified-Since");
    32273234  const char *inm = mg_get_header(conn, "If-None-Match");
    3228   construct_etag(etag, sizeof(etag), filep);
     3235  construct_etag(conn, path, etag, sizeof(etag), filep);
    32293236  return (inm != NULL && !mg_strcasecmp(etag, inm)) ||
    32303237    (ims != NULL && filep->modification_time <= parse_date_string(ims));
     
    45924599                          path) > 0) {
    45934600    handle_ssi_file_request(conn, path);
    4594   } else if (is_not_modified(conn, &file)) {
     4601  } else if (is_not_modified(conn, path, &file)) {
    45954602    send_http_error(conn, 304, "Not Modified", "%s", "");
    45964603  } else {
Note: See TracChangeset for help on using the changeset viewer.