*** mod_headers.c 2021-06-15 10:46:30.674015211 +0200 --- mod_headers.c-patch 2021-06-15 10:44:06.309063319 +0200 *************** static int add_them_all(void *v, const c *** 691,697 **** } static int do_headers_fixup(request_rec *r, apr_table_t *headers, ! apr_array_header_t *fixup, int early) { echo_do v; int i; --- 691,697 ---- } static int do_headers_fixup(request_rec *r, apr_table_t *headers, ! apr_array_header_t *fixup, int early, int locationonly) { echo_do v; int i; *************** static int do_headers_fixup(request_rec *** 701,706 **** --- 701,711 ---- header_entry *hdr = &((header_entry *) (fixup->elts))[i]; const char *envar = hdr->condition_var; + /* ignore other headers if only Location is needed (special treatment of Location according to http_protocol.c */ + if (locationonly && ap_cstr_casecmp(hdr->header, "Location")) { + continue; + } + /* ignore early headers in late calls */ if (!early && (envar == condition_early)) { continue; *************** static apr_status_t ap_headers_output_fi *** 866,873 **** "headers: ap_headers_output_filter()"); /* do the fixup */ ! do_headers_fixup(f->r, f->r->err_headers_out, dirconf->fixup_err, 0); ! do_headers_fixup(f->r, f->r->headers_out, dirconf->fixup_out, 0); /* remove ourselves from the filter chain */ ap_remove_output_filter(f); --- 871,878 ---- "headers: ap_headers_output_filter()"); /* do the fixup */ ! do_headers_fixup(f->r, f->r->err_headers_out, dirconf->fixup_err, 0, 0); ! do_headers_fixup(f->r, f->r->headers_out, dirconf->fixup_out, 0, 0); /* remove ourselves from the filter chain */ ap_remove_output_filter(f); *************** static apr_status_t ap_headers_error_fil *** 894,900 **** * Add any header fields defined by "Header always" to r->err_headers_out. * Server-wide first, then per-directory to allow overriding. */ ! do_headers_fixup(f->r, f->r->err_headers_out, dirconf->fixup_err, 0); /* * We've done our bit; remove ourself from the filter chain so there's --- 899,906 ---- * Add any header fields defined by "Header always" to r->err_headers_out. * Server-wide first, then per-directory to allow overriding. */ ! do_headers_fixup(f->r, f->r->err_headers_out, dirconf->fixup_err, 0, 0); ! do_headers_fixup(f->r, f->r->headers_out, dirconf->fixup_err, 0, 1); /* * We've done our bit; remove ourself from the filter chain so there's *************** static apr_status_t ap_headers_fixup(req *** 915,921 **** /* do the fixup */ if (dirconf->fixup_in->nelts) { ! do_headers_fixup(r, r->headers_in, dirconf->fixup_in, 0); } return DECLINED; --- 921,927 ---- /* do the fixup */ if (dirconf->fixup_in->nelts) { ! do_headers_fixup(r, r->headers_in, dirconf->fixup_in, 0, 0); } return DECLINED; *************** static apr_status_t ap_headers_early(req *** 927,941 **** /* do the fixup */ if (dirconf->fixup_in->nelts) { ! if (!do_headers_fixup(r, r->headers_in, dirconf->fixup_in, 1)) goto err; } if (dirconf->fixup_err->nelts) { ! if (!do_headers_fixup(r, r->err_headers_out, dirconf->fixup_err, 1)) goto err; } if (dirconf->fixup_out->nelts) { ! if (!do_headers_fixup(r, r->headers_out, dirconf->fixup_out, 1)) goto err; } --- 933,947 ---- /* do the fixup */ if (dirconf->fixup_in->nelts) { ! if (!do_headers_fixup(r, r->headers_in, dirconf->fixup_in, 1, 0)) goto err; } if (dirconf->fixup_err->nelts) { ! if (!do_headers_fixup(r, r->err_headers_out, dirconf->fixup_err, 1, 0)) goto err; } if (dirconf->fixup_out->nelts) { ! if (!do_headers_fixup(r, r->headers_out, dirconf->fixup_out, 1, 0)) goto err; }