added mime types for missing filetypes; made static content cacheable for 14 days
Costa Tsaousis (ktsaou) committed
Feb 26, 2016 at 00:31 UTC
4677d50503f2c13da66838d35e04b3d96cd751fc
2 files changed
+38
-1
src/web_buffer.h
+6
@@ -36,6 +36,12 @@ typedef struct web_buffer {
36
#define CT_APPLICATION_FONT_WOFF2 13
37
#define CT_APPLICATION_VND_MS_FONTOBJ 14
38
#define CT_IMAGE_SVG_XML 15
39
+#define CT_IMAGE_PNG 16
40
+#define CT_IMAGE_JPG 17
41
+#define CT_IMAGE_GIF 18
42
+#define CT_IMAGE_XICON 19
43
+#define CT_IMAGE_ICNS 20
44
+#define CT_IMAGE_BMP 21
45
46
#define buffer_strlen(wb) ((wb)->len)
47
extern const char *buffer_tostring(BUFFER *wb);
src/web_client.c
+32
-1
@@ -341,6 +341,13 @@ int mysendfile(struct web_client *w, char *filename)
341
else if(strstr(filename, ".woff2")!= NULL) w->response.data->contenttype = CT_APPLICATION_FONT_WOFF2;
342
else if(strstr(filename, ".woff") != NULL) w->response.data->contenttype = CT_APPLICATION_FONT_WOFF;
343
else if(strstr(filename, ".eot") != NULL) w->response.data->contenttype = CT_APPLICATION_VND_MS_FONTOBJ;
344
+ else if(strstr(filename, ".png") != NULL) w->response.data->contenttype = CT_IMAGE_PNG;
345
+ else if(strstr(filename, ".jpg") != NULL) w->response.data->contenttype = CT_IMAGE_JPG;
346
+ else if(strstr(filename, ".jpeg") != NULL) w->response.data->contenttype = CT_IMAGE_JPG;
347
+ else if(strstr(filename, ".gif") != NULL) w->response.data->contenttype = CT_IMAGE_GIF;
348
+ else if(strstr(filename, ".bmp") != NULL) w->response.data->contenttype = CT_IMAGE_BMP;
349
+ else if(strstr(filename, ".ico") != NULL) w->response.data->contenttype = CT_IMAGE_XICON;
350
+ else if(strstr(filename, ".icns") != NULL) w->response.data->contenttype = CT_IMAGE_ICNS;
351
else w->response.data->contenttype = CT_APPLICATION_OCTET_STREAM;
352
353
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending file '%s' (%ld bytes, ifd %d, ofd %d).", w->id, webfilename, stat.st_size, w->ifd, w->ofd);
@@ -1266,6 +1273,30 @@ void web_client_process(struct web_client *w) {
1273
content_type_string = "application/vnd.ms-fontobject";
1274
break;
1275
1276
+ case CT_IMAGE_PNG:
1277
+ content_type_string = "image/png";
1278
+ break;
1279
+
1280
+ case CT_IMAGE_JPG:
1281
+ content_type_string = "image/jpeg";
1282
+ break;
1283
+
1284
+ case CT_IMAGE_GIF:
1285
+ content_type_string = "image/gif";
1286
+ break;
1287
+
1288
+ case CT_IMAGE_XICON:
1289
+ content_type_string = "image/x-icon";
1290
+ break;
1291
+
1292
+ case CT_IMAGE_BMP:
1293
+ content_type_string = "image/bmp";
1294
+ break;
1295
+
1296
+ case CT_IMAGE_ICNS:
1297
+ content_type_string = "image/icns";
1298
+ break;
1299
+
1300
default:
1301
case CT_TEXT_PLAIN:
1302
content_type_string = "text/plain; charset=utf-8";
@@ -1330,7 +1361,7 @@ void web_client_process(struct web_client *w) {
1361
}
1362
else {
1363
char edate[100];
1333
- time_t et = w->response.data->date + 86400;
1364
+ time_t et = w->response.data->date + (86400 * 14);
1365
struct tm etmbuf, *etm = gmtime_r(&et, &etmbuf);
1366
strftime(edate, sizeof(edate), "%a, %d %b %Y %H:%M:%S %Z", etm);
1367