Changeset c3353ae5 in rtems
- Timestamp:
- 03/08/18 04:12:30 (5 years ago)
- 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)
- Location:
- cpukit/mghttpd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/mghttpd/mongoose.c
r7093cb5e rc3353ae5 2990 2990 } 2991 2991 2992 static void construct_etag(char *buf, size_t buf_len, 2992 static void construct_etag(const struct mg_connection *conn, const char *path, 2993 char *buf, size_t buf_len, 2993 2994 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 } 2996 3002 } 2997 3003 … … 3062 3068 gmt_time_string(date, sizeof(date), &curtime); 3063 3069 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); 3065 3071 3066 3072 (void) mg_printf(conn, … … 3222 3228 // Return True if we should reply 304 Not Modified. 3223 3229 static int is_not_modified(const struct mg_connection *conn, 3230 const char *path, 3224 3231 const struct file *filep) { 3225 3232 char etag[64]; 3226 3233 const char *ims = mg_get_header(conn, "If-Modified-Since"); 3227 3234 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); 3229 3236 return (inm != NULL && !mg_strcasecmp(etag, inm)) || 3230 3237 (ims != NULL && filep->modification_time <= parse_date_string(ims)); … … 4592 4599 path) > 0) { 4593 4600 handle_ssi_file_request(conn, path); 4594 } else if (is_not_modified(conn, &file)) {4601 } else if (is_not_modified(conn, path, &file)) { 4595 4602 send_http_error(conn, 304, "Not Modified", "%s", ""); 4596 4603 } else { -
cpukit/mghttpd/mongoose.h
r7093cb5e rc3353ae5 125 125 // status: HTTP error status code. 126 126 int (*http_error)(struct mg_connection *, int status); 127 128 // Called when mongoose needs to generate an HTTP etag. 129 // Implementing this callback allows a custom etag to be generated. If 130 // not implemented the standard etag generator is used which is the 131 // modification time as a hex value and the file size. 132 // Use this callback if the modification time cannot be controlled. 133 // Parameters: 134 // path: path to the file being requested 135 // etag: buffer to write the etag into 136 // etag_len: the length of the etag buffer 137 // Return value: 138 int (*http_etag)(const struct mg_connection *, 139 const char *path, char *etag, size_t etag_len); 127 140 }; 128 141
Note: See TracChangeset
for help on using the changeset viewer.