From 074a33046a0e85bf563c0f2f84bb8a4d3e748a74 Mon Sep 17 00:00:00 2001 From: Brainedia <187246+robertsass@users.noreply.github.com> Date: Fri, 3 May 2019 16:53:14 +0200 Subject: [PATCH 1/3] Added Flag "XSendFileUnsetContentEncoding" Based on the idea of ailmanki https://forums.freebsd.org/threads/port-mod_xsendfile.57330/ --- mod_xsendfile.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mod_xsendfile.c b/mod_xsendfile.c index 863ed26..56f5196 100644 --- a/mod_xsendfile.c +++ b/mod_xsendfile.c @@ -149,6 +149,9 @@ static const char *xsendfile_cmd_flag(cmd_parms *cmd, void *perdir_confv, else if (!strcasecmp(cmd->cmd->name, "xsendfileunescape")) { conf->unescape = flag ? XSENDFILE_ENABLED: XSENDFILE_DISABLED; } + else if (!strcasecmp(cmd->cmd->name, "xsendfileunsetcontentencoding")) { + conf->unsetCE = flag ? XSENDFILE_ENABLED: XSENDFILE_DISABLED; + } else { return apr_psprintf( cmd->pool, @@ -395,8 +398,10 @@ static apr_status_t ap_xsendfile_output_filter(ap_filter_t *f, apr_bucket_brigad /* as we dropped all the content this field is not valid anymore! */ apr_table_unset(r->headers_out, "Content-Length"); apr_table_unset(r->err_headers_out, "Content-Length"); - apr_table_unset(r->headers_out, "Content-Encoding"); - apr_table_unset(r->err_headers_out, "Content-Encoding"); + if (conf->unsetCE != XSENDFILE_DISABLED) { + apr_table_unset(r->headers_out, "Content-Encoding"); + apr_table_unset(r->err_headers_out, "Content-Encoding"); + } /* Decode header lighttpd does the same for X-Sendfile2, so we're compatible here @@ -676,6 +681,13 @@ static const command_rec xsendfile_command_table[] = { OR_FILEINFO, "On|Off - Unescape/url-decode the value of the header (default: On)" ), + AP_INIT_FLAG( + "XSendFileUnsetContentEncoding", + xsendfile_cmd_flag, + NULL, + OR_FILEINFO, + "On|Off - Unsets the Content-Encoding header (default: On)" + ), AP_INIT_TAKE12( "XSendFilePath", xsendfile_cmd_path, From 9aff806524a69f8a8c71060a3038794d5313ba7b Mon Sep 17 00:00:00 2001 From: Brainedia <187246+robertsass@users.noreply.github.com> Date: Fri, 3 May 2019 17:10:57 +0200 Subject: [PATCH 2/3] Added flag "XSendFileUnsetContentEncoding" Based on the idea of ailmanki https://forums.freebsd.org/threads/port-mod_xsendfile.57330/ --- mod_xsendfile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mod_xsendfile.c b/mod_xsendfile.c index 56f5196..a0fbc52 100644 --- a/mod_xsendfile.c +++ b/mod_xsendfile.c @@ -72,6 +72,7 @@ typedef struct xsendfile_conf_t { xsendfile_conf_active_t ignoreETag; xsendfile_conf_active_t ignoreLM; xsendfile_conf_active_t unescape; + xsendfile_conf_active_t unsetCE; apr_array_header_t *paths; apr_array_header_t *temporaryPaths; } xsendfile_conf_t; @@ -86,9 +87,10 @@ static xsendfile_conf_t *xsendfile_config_create(apr_pool_t *p) { xsendfile_conf_t *conf; conf = (xsendfile_conf_t *) apr_pcalloc(p, sizeof(xsendfile_conf_t)); - conf->unescape = + conf->unescape = conf->ignoreETag = conf->ignoreLM = + conf->unsetCE = conf->enabled = XSENDFILE_UNSET; @@ -114,6 +116,7 @@ static void *xsendfile_config_merge(apr_pool_t *p, void *basev, void *overridesv XSENDFILE_CFLAG(ignoreETag); XSENDFILE_CFLAG(ignoreLM); XSENDFILE_CFLAG(unescape); + XSENDFILE_CFLAG(unsetCE); conf->paths = apr_array_append(p, overrides->paths, base->paths); From c859709c2dfa997f7623e8ca43dacea305dc6cb7 Mon Sep 17 00:00:00 2001 From: Brainedia <187246+robertsass@users.noreply.github.com> Date: Fri, 3 May 2019 17:14:29 +0200 Subject: [PATCH 3/3] Added flag "XSendFileUnsetContentEncoding" To supress unsetting of the Content-Encoding header - e.g. if you want to deliver files that are gzip compressed. Based on the idea of ailmanki https://forums.freebsd.org/threads/port-mod_xsendfile.57330/ --- mod_xsendfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mod_xsendfile.c b/mod_xsendfile.c index a0fbc52..a1418f4 100644 --- a/mod_xsendfile.c +++ b/mod_xsendfile.c @@ -17,6 +17,7 @@ * Nils Maier * Ben Timby - URL decoding * Jake Rhee - X-SENDFILE-TEMPORARY + * Robert Saß - XSendFileUnsetContentEncoding ****/ /****