Debian Codegraph @

modules/caddyhttp/headers/headers.go

raw symbols SCIP
1 // Copyright 2015 Matthew Holt and The Caddy Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package headersscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/"
19 "net/httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/"
20 "regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/"
21 "stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/"
22
23 "github.com/caddyserver/caddy/v2scip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/"
24 "github.com/caddyserver/caddy/v2/modules/caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/"
25 )
26
27 func initscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/init().() {
28 caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.RegisterModulescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/RegisterModule().(Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#{})
29 }
30
31 // Handler is a middleware which modifies request and response headers.
32 //
33 // Changes to headers are applied immediately, except for the response
34 // headers when Deferred is true or when Required is set. In those cases,
35 // the changes are applied when the headers are written to the response.
36 // Note that deferred changes do not take effect if an error occurs later
37 // in the middleware chain.
38 //
39 // Properties in this module accept placeholders.
40 //
41 // Response header operations can be conditioned upon response status code
42 // and/or other header values.
43 type Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler# struct {
44 Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request. *HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps# `json:"request,omitempty"`
45 Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response. *RespHeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps# `json:"response,omitempty"`
46 }
47
48 // CaddyModule returns the Caddy module information.
49 func (Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#) CaddyModulescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#CaddyModule().() caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ModuleInfoscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ModuleInfo# {
50 return caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ModuleInfoscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ModuleInfo#{
51 IDscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ModuleInfo#ID.: "http.handlers.headers",
52 Newscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ModuleInfo#New.: func() caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Modulescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Module# { return new(Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#) },
53 }
54 }
55
56 // Provision sets up h's configuration.
57 func (h *Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#) Provisionscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Provision().(ctx caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Contextscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Context#) error {
58 if h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request. != nil {
59 err := h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request..Provisionscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Provision().(ctx)
60 if err != nil {
61 return err
62 }
63 }
64 if h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response. != nil {
65 err := h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..Provisionscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Provision().(ctx)
66 if err != nil {
67 return err
68 }
69 }
70 return nil
71 }
72
73 // Validate ensures h's configuration is valid.
74 func (h Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#) Validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Validate().() error {
75 if h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request. != nil {
76 err := h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request..validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#validate().()
77 if err != nil {
78 return err
79 }
80 }
81 if h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response. != nil && h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#HeaderOps. != nil {
82 err := h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#validate().()
83 if err != nil {
84 return err
85 }
86 }
87 return nil
88 }
89
90 func (h Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#) ServeHTTPscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#ServeHTTP().(w httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#, next caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/Handler#) error {
91 repl := r.Contextscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Context().().Valuescip-go gomod github.com/golang/go/src go1.25.1 context/Context#Value().(caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ReplacerCtxKeyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ReplacerCtxKey.).(*caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#)
92
93 if h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request. != nil {
94 h.Requestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Request..ApplyToRequestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyToRequest().(r)
95 }
96
97 if h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response. != nil {
98 if h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..Deferredscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#Deferred. || h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..Requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#Require. != nil {
99 w = &responseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#{
100 ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper.: &caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/ResponseWriterWrapper#{ResponseWriterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/ResponseWriterWrapper#ResponseWriter.: w},
101 replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#replacer.: repl,
102 requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#require.: h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..Requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#Require.,
103 headerOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#headerOps.: h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#HeaderOps.,
104 }
105 } else {
106 h.Responsescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#Response..ApplyToscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyTo().(w.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#Header().(), repl)
107 }
108 }
109
110 return next.ServeHTTPscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/Handler#ServeHTTP.(w, r)
111 }
112
113 // HeaderOps defines manipulations for HTTP headers.
114 type HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps# struct {
115 // Adds HTTP headers; does not replace any existing header fields.
116 Addscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Add. httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header# `json:"add,omitempty"`
117
118 // Sets HTTP headers; replaces existing header fields.
119 Setscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Set. httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header# `json:"set,omitempty"`
120
121 // Names of HTTP header fields to delete. Basic wildcards are supported:
122 //
123 // - Start with `*` for all field names with the given suffix;
124 // - End with `*` for all field names with the given prefix;
125 // - Start and end with `*` for all field names containing a substring.
126 Deletescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Delete. []string `json:"delete,omitempty"`
127
128 // Performs in-situ substring replacements of HTTP headers.
129 // Keys are the field names on which to perform the associated replacements.
130 // If the field name is `*`, the replacements are performed on all header fields.
131 Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Replace. map[string][]Replacementscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement# `json:"replace,omitempty"`
132 }
133
134 // Provision sets up the header operations.
135 func (ops *HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#) Provisionscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Provision().(_ caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Contextscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Context#) error {
136 if ops == nil {
137 return nil // it's possible no ops are configured; fix #6893
138 }
139 for fieldName, replacements := range ops.Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Replace. {
140 for i, r := range replacements {
141 if r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp. == "" {
142 continue
143 }
144
145 // Check if it contains placeholders
146 if containsPlaceholdersscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/containsPlaceholders().(r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp.) {
147 // Contains placeholders, skips precompilation, and recompiles at runtime
148 continue
149 }
150
151 // Does not contain placeholders, safe to precompile
152 re, err := regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25.1 regexp/Compile().(r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp.)
153 if err != nil {
154 return fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Errorf().("replacement %d for header field '%s': %v", i, fieldName, err)
155 }
156 replacements[i].rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re. = re
157 }
158 }
159 return nil
160 }
161
162 // containsPlaceholders checks if the string contains Caddy placeholder syntax {key}
163 func containsPlaceholdersscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/containsPlaceholders().(s string) bool {
164 _, after, ok := stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.Cutscip-go gomod github.com/golang/go/src go1.25.1 strings/Cut().(s, "{")
165 if !ok {
166 return false
167 }
168 closeIdx := stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.Indexscip-go gomod github.com/golang/go/src go1.25.1 strings/Index().(after, "}")
169 if closeIdx == -1 {
170 return false
171 }
172 // Make sure there is content between the brackets
173 return closeIdx > 0
174 }
175
176 func (ops HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#) validatescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#validate().() error {
177 for fieldName, replacements := range ops.Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Replace. {
178 for _, r := range replacements {
179 if r.Searchscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Search. != "" && r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp. != "" {
180 return fmtscip-go gomod github.com/golang/go/src go1.25.1 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.1 fmt/Errorf().("cannot specify both a substring search and a regular expression search for field '%s'", fieldName)
181 }
182 }
183 }
184 return nil
185 }
186
187 // Replacement describes a string replacement,
188 // either a simple and fast substring search
189 // or a slower but more powerful regex search.
190 type Replacementscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement# struct {
191 // The substring to search for.
192 Searchscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Search. string `json:"search,omitempty"`
193
194 // The regular expression to search with.
195 SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp. string `json:"search_regexp,omitempty"`
196
197 // The string with which to replace matches.
198 Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Replace. string `json:"replace,omitempty"`
199
200 rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re. *regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#
201 }
202
203 // RespHeaderOps defines manipulations for response headers.
204 type RespHeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps# struct {
205 *HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#HeaderOps.
206
207 // If set, header operations will be deferred until
208 // they are written out and only performed if the
209 // response matches these criteria.
210 Requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#Require. *caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.ResponseMatcherscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/ResponseMatcher# `json:"require,omitempty"`
211
212 // If true, header operations will be deferred until
213 // they are written out. Superseded if Require is set.
214 // Usually you will need to set this to true if any
215 // fields are being deleted.
216 Deferredscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/RespHeaderOps#Deferred. bool `json:"deferred,omitempty"`
217 }
218
219 // ApplyTo applies ops to hdr using repl.
220 func (ops *HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#) ApplyToscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyTo().(hdr httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#, repl *caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#) {
221 if ops == nil {
222 return
223 }
224 // before manipulating headers in other ways, check if there
225 // is configuration to delete all headers, and do that first
226 // because if a header is to be added, we don't want to delete
227 // it also
228 for _, fieldName := range ops.Deletescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Delete. {
229 fieldName = repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(fieldName, "")
230 if fieldName == "*" {
231 clear(hdr)
232 }
233 }
234
235 // add
236 for fieldName, vals := range ops.Addscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Add. {
237 fieldName = repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(fieldName, "")
238 for _, v := range vals {
239 hdr.Addscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#Add().(fieldName, repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(v, ""))
240 }
241 }
242
243 // set
244 for fieldName, vals := range ops.Setscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Set. {
245 fieldName = repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(fieldName, "")
246 var newVals []string
247 for i := range vals {
248 // append to new slice so we don't overwrite
249 // the original values in ops.Set
250 newVals = append(newVals, repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(vals[i], ""))
251 }
252 hdr.Setscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#Set().(fieldName, stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.1 strings/Join().(newVals, ","))
253 }
254
255 // delete
256 for _, fieldName := range ops.Deletescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Delete. {
257 fieldName = stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(fieldName, ""))
258 if fieldName == "*" {
259 continue // handled above
260 }
261 switch {
262 case stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasPrefix().(fieldName, "*") && stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasSuffix().(fieldName, "*"):
263 for existingField := range hdr {
264 if stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.1 strings/Contains().(stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(existingField), fieldName[1:len(fieldName)-1]) {
265 delete(hdr, existingField)
266 }
267 }
268 case stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasPrefix().(fieldName, "*"):
269 for existingField := range hdr {
270 if stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasSuffix().(stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(existingField), fieldName[1:]) {
271 delete(hdr, existingField)
272 }
273 }
274 case stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasSuffix().(fieldName, "*"):
275 for existingField := range hdr {
276 if stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.1 strings/HasPrefix().(stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ToLowerscip-go gomod github.com/golang/go/src go1.25.1 strings/ToLower().(existingField), fieldName[:len(fieldName)-1]) {
277 delete(hdr, existingField)
278 }
279 }
280 default:
281 hdr.Delscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Header#Del().(fieldName)
282 }
283 }
284
285 // replace
286 for fieldName, replacements := range ops.Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#Replace. {
287 fieldName = httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.CanonicalHeaderKeyscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/CanonicalHeaderKey().(repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(fieldName, ""))
288
289 // all fields...
290 if fieldName == "*" {
291 for _, r := range replacements {
292 search := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.Searchscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Search., "")
293 replace := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Replace., "")
294 for fieldName, vals := range hdr {
295 for i := range vals {
296 if r.rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re. != nil {
297 // Use precompiled regular expressions
298 hdr[fieldName][i] = r.rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re..ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#ReplaceAllString().(hdr[fieldName][i], replace)
299 } else if r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp. != "" {
300 // Runtime compilation of regular expressions
301 searchRegexp := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp., "")
302 if re, err := regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25.1 regexp/Compile().(searchRegexp); err == nil {
303 hdr[fieldName][i] = re.ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#ReplaceAllString().(hdr[fieldName][i], replace)
304 }
305 // If compilation fails, skip this replacement
306 } else {
307 hdr[fieldName][i] = stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.25.1 strings/ReplaceAll().(hdr[fieldName][i], search, replace)
308 }
309 }
310 }
311 }
312 continue
313 }
314
315 // ...or only with the named field
316 for _, r := range replacements {
317 search := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.Searchscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Search., "")
318 replace := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.Replacescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#Replace., "")
319 for hdrFieldName, vals := range hdr {
320 // see issue #4330 for why we don't simply use hdr[fieldName]
321 if httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.CanonicalHeaderKeyscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/CanonicalHeaderKey().(hdrFieldName) != fieldName {
322 continue
323 }
324 for i := range vals {
325 if r.rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re. != nil {
326 hdr[hdrFieldName][i] = r.rescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#re..ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#ReplaceAllString().(hdr[hdrFieldName][i], replace)
327 } else if r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp. != "" {
328 searchRegexp := repl.ReplaceKnownscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#ReplaceKnown().(r.SearchRegexpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Replacement#SearchRegexp., "")
329 if re, err := regexpscip-go gomod github.com/golang/go/src go1.25.1 regexp/.Compilescip-go gomod github.com/golang/go/src go1.25.1 regexp/Compile().(searchRegexp); err == nil {
330 hdr[hdrFieldName][i] = re.ReplaceAllStringscip-go gomod github.com/golang/go/src go1.25.1 regexp/Regexp#ReplaceAllString().(hdr[hdrFieldName][i], replace)
331 }
332 } else {
333 hdr[hdrFieldName][i] = stringsscip-go gomod github.com/golang/go/src go1.25.1 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.25.1 strings/ReplaceAll().(hdr[hdrFieldName][i], search, replace)
334 }
335 }
336 }
337 }
338 }
339 }
340
341 // ApplyToRequest applies ops to r, specially handling the Host
342 // header which the standard library does not include with the
343 // header map with all the others. This method mutates r.Host.
344 func (ops HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#) ApplyToRequestscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyToRequest().(r *httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#) {
345 repl := r.Contextscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Context().().Valuescip-go gomod github.com/golang/go/src go1.25.1 context/Context#Value().(caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.ReplacerCtxKeyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ReplacerCtxKey.).(*caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#)
346
347 // capture the current Host header so we can
348 // reset to it when we're done
349 origHost, hadHost := r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"]
350
351 // append r.Host; this way, we know that our value
352 // was last in the list, and if an Add operation
353 // appended something else after it, that's probably
354 // fine because it's weird to have multiple Host
355 // headers anyway and presumably the one they added
356 // is the one they wanted
357 r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"] = append(r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"], r.Hostscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Host.)
358
359 // apply header operations
360 ops.ApplyToscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyTo().(r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header., repl)
361
362 // retrieve the last Host value (likely the one we appended)
363 if len(r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"]) > 0 {
364 r.Hostscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Host. = r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"][len(r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"])-1]
365 } else {
366 r.Hostscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Host. = ""
367 }
368
369 // reset the Host header slice
370 if hadHost {
371 r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header.["Host"] = origHost
372 } else {
373 delete(r.Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Header., "Host")
374 }
375 }
376
377 // responseWriterWrapper defers response header
378 // operations until WriteHeader is called.
379 type responseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper# struct {
380 *caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper.
381 replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#replacer. *caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Replacer#
382 requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#require. *caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.ResponseMatcherscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/ResponseMatcher#
383 headerOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#headerOps. *HeaderOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#
384 wroteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#wroteHeader. bool
385 }
386
387 func (rww *responseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#) WriteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#WriteHeader().(status int) {
388 if rww.wroteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#wroteHeader. {
389 return
390 }
391 // 1xx responses aren't final; just informational
392 if status < 100 || status > 199 {
393 rww.wroteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#wroteHeader. = true
394 }
395 if rww.requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#require. == nil || rww.requirescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#require..Matchscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/ResponseMatcher#Match().(status, rww.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper..Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#Header().()) {
396 if rww.headerOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#headerOps. != nil {
397 rww.headerOpsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#headerOps..ApplyToscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/HeaderOps#ApplyTo().(rww.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper..Headerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#Header().(), rww.replacerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#replacer.)
398 }
399 }
400 rww.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper..WriteHeaderscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#WriteHeader().(status)
401 }
402
403 func (rww *responseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#) Writescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#Write().(d []byte) (int, error) {
404 if !rww.wroteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#wroteHeader. {
405 rww.WriteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#WriteHeader().(httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.StatusOKscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/StatusOK.)
406 }
407 return rww.ResponseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#ResponseWriterWrapper..Writescip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#Write().(d)
408 }
409
410 // Interface guards
411 var (
412 _ caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/.Provisionerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/Provisioner# = (*Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#)(nil)
413 _ caddyhttpscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/.MiddlewareHandlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp`/MiddlewareHandler# = (*Handlerscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/Handler#)(nil)
414 _ httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter# = (*responseWriterWrapperscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/modules/caddyhttp/headers`/responseWriterWrapper#)(nil)
415 )