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;
}
}
if (enc != 0) {
http_add_header_field(&res.hdr, "Vary", "Accept-Encoding");
}
}
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;
int http_comp = http_get_compression(&req, &res);
if (http_comp & COMPRESS) {
if (http_comp & COMPRESS_BR) {
use_fastcgi |= FASTCGI_COMPRESS_BR;
http_add_header_field(&res.hdr, "Content-Encoding", "br");
sprintf(buf0, "br");
} else if (http_comp & COMPRESS_GZ) {
use_fastcgi |= FASTCGI_COMPRESS_GZ;
http_add_header_field(&res.hdr, "Content-Encoding", "gzip");
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) {

View File

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