From ffbbcc649072237c2b2ac3052b11d6779951a955 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 4 May 2021 22:36:29 +0200 Subject: [PATCH] Fix makefile --- Makefile | 2 +- src/client.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f9cd357..7314eaf 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CFLAGS=-std=c11 -Wall INCLUDE=-lssl -lcrypto -lmagic -lz -lmaxminddb -lbrotlienc LIBS=src/lib/*.c -DEBIAN_OPTS=-D MAGIC_FILE="\"/usr/share/file/magic.mgc\"" -D PHP_FPM_SOCKET="\"/var/run/php/php7.3-fpm.sock\"" +DEBIAN_OPTS=-D CACHE_MAGIC_FILE="\"/usr/share/file/magic.mgc\"" -D PHP_FPM_SOCKET="\"/var/run/php/php7.3-fpm.sock\"" packages: @echo "Installing packages..." diff --git a/src/client.c b/src/client.c index cd4142a..9a55b48 100644 --- a/src/client.c +++ b/src/client.c @@ -407,10 +407,14 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int char *accept_encoding = http_get_header_field(&req.hdr, "Accept-Encoding"); char *content_type = http_get_header_field(&res.hdr, "Content-Type"); char *content_encoding = http_get_header_field(&res.hdr, "Content-Encoding"); - if (mime_is_compressible(content_type) && content_encoding == NULL && - accept_encoding != NULL && strstr(accept_encoding, "deflate") != NULL) { - http_add_header_field(&res.hdr, "Content-Encoding", "deflate"); - use_fastcgi = 2; + if (mime_is_compressible(content_type) && content_encoding == NULL && accept_encoding != NULL) { + if (strstr(accept_encoding, "br") != NULL) { + http_add_header_field(&res.hdr, "Content-Encoding", "br"); + use_fastcgi = FASTCGI_COMPRESS_BR; + } else if (strstr(accept_encoding, "gzip") != NULL) { + http_add_header_field(&res.hdr, "Content-Encoding", "gzip"); + use_fastcgi = FASTCGI_COMPRESS_GZ; + } } if (http_get_header_field(&res.hdr, "Content-Length") == NULL) { @@ -508,7 +512,7 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int } else if (use_fastcgi) { char *transfer_encoding = http_get_header_field(&res.hdr, "Transfer-Encoding"); int chunked = transfer_encoding != NULL && strcmp(transfer_encoding, "chunked") == 0; - int flags = (chunked ? FASTCGI_CHUNKED : 0) | ((use_fastcgi == 2) ? FASTCGI_COMPRESS : 0); + int flags = (chunked ? FASTCGI_CHUNKED : 0) | (use_fastcgi & FASTCGI_COMPRESS); fastcgi_send(&php_fpm, client, flags); } else if (use_rev_proxy) { char *transfer_encoding = http_get_header_field(&res.hdr, "Transfer-Encoding");