Added Vary header

This commit is contained in:
2021-05-06 20:55:44 +02:00
parent 7aa47cac61
commit cf2c0de697
2 changed files with 14 additions and 6 deletions

View File

@ -286,6 +286,9 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
enc = COMPRESS_GZ; enc = COMPRESS_GZ;
} }
} }
if (enc != 0) {
http_add_header_field(&res.hdr, "Vary", "Accept-Encoding");
}
} }
if (uri.meta->etag[0] != 0) { if (uri.meta->etag[0] != 0) {
@ -421,12 +424,16 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int
use_fastcgi = 1; use_fastcgi = 1;
int http_comp = http_get_compression(&req, &res); int http_comp = http_get_compression(&req, &res);
if (http_comp & COMPRESS_BR) { if (http_comp & COMPRESS) {
use_fastcgi |= FASTCGI_COMPRESS_BR; if (http_comp & COMPRESS_BR) {
http_add_header_field(&res.hdr, "Content-Encoding", "br"); use_fastcgi |= FASTCGI_COMPRESS_BR;
} else if (http_comp & COMPRESS_GZ) { sprintf(buf0, "br");
use_fastcgi |= FASTCGI_COMPRESS_GZ; } else if (http_comp & COMPRESS_GZ) {
http_add_header_field(&res.hdr, "Content-Encoding", "gzip"); use_fastcgi |= FASTCGI_COMPRESS_GZ;
sprintf(buf0, "gzip");
}
http_add_header_field(&res.hdr, "Vary", "Accept-Encoding");
http_add_header_field(&res.hdr, "Content-Encoding", buf0);
} }
if (http_get_header_field(&res.hdr, "Content-Length") == NULL) { if (http_get_header_field(&res.hdr, "Content-Length") == NULL) {

View File

@ -16,6 +16,7 @@
#define COMPRESS_GZ 1 #define COMPRESS_GZ 1
#define COMPRESS_BR 2 #define COMPRESS_BR 2
#define COMPRESS 3
typedef struct { typedef struct {
int mode; int mode;