MCPcopy Create free account
hub / github.com/apache/httpd / do_headers_fixup

Function do_headers_fixup

modules/metadata/mod_headers.c:697–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695}
696
697static int do_headers_fixup(request_rec *r, apr_table_t *headers,
698 apr_array_header_t *fixup, int early)
699{
700 echo_do v;
701 int i;
702 const char *val;
703
704 for (i = 0; i < fixup->nelts; ++i) {
705 header_entry *hdr = &((header_entry *) (fixup->elts))[i];
706 const char *envar = hdr->condition_var;
707
708 /* ignore early headers in late calls */
709 if (!early && (envar == condition_early)) {
710 continue;
711 }
712 /* ignore late headers in early calls */
713 else if (early && (envar != condition_early)) {
714 continue;
715 }
716 /* Do we have an expression to evaluate? */
717 else if (hdr->expr != NULL) {
718 const char *err = NULL;
719 int eval = ap_expr_exec(r, hdr->expr, &err);
720 if (err) {
721 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01501)
722 "Failed to evaluate expression (%s) - ignoring",
723 err);
724 }
725 else if (!eval) {
726 continue;
727 }
728 }
729 /* Have any conditional envar-controlled Header processing to do? */
730 else if (envar && !early) {
731 if (*envar != '!') {
732 if (apr_table_get(r->subprocess_env, envar) == NULL)
733 continue;
734 }
735 else {
736 if (apr_table_get(r->subprocess_env, &envar[1]) != NULL)
737 continue;
738 }
739 }
740
741 switch (hdr->action) {
742 case hdr_add:
743 apr_table_addn(headers, hdr->header, process_tags(hdr, r));
744 break;
745 case hdr_append:
746 apr_table_mergen(headers, hdr->header, process_tags(hdr, r));
747 break;
748 case hdr_merge:
749 val = apr_table_get(headers, hdr->header);
750 if (val == NULL) {
751 apr_table_addn(headers, hdr->header, process_tags(hdr, r));
752 } else {
753 char *new_val = process_tags(hdr, r);
754 apr_size_t new_val_len = strlen(new_val);

Callers 4

ap_headers_output_filterFunction · 0.85
ap_headers_error_filterFunction · 0.85
ap_headers_fixupFunction · 0.85
ap_headers_earlyFunction · 0.85

Calls 6

ap_expr_execFunction · 0.85
process_tagsFunction · 0.85
ap_cstr_casecmpFunction · 0.85
ap_set_content_typeFunction · 0.85
process_regexpFunction · 0.85
ap_set_content_type_exFunction · 0.85

Tested by

no test coverage detected