MCPcopy
hub / github.com/caddyserver/caddy / initializePushHeaders

Method initializePushHeaders

modules/caddyhttp/push/handler.go:136–160  ·  view source on GitHub ↗
(r *http.Request, repl *caddy.Replacer)

Source from the content-addressed store, hash-verified

134}
135
136func (h Handler) initializePushHeaders(r *http.Request, repl *caddy.Replacer) http.Header {
137 hdr := make(http.Header)
138
139 // prevent recursive pushes
140 hdr.Set(pushHeader, "1")
141
142 // set initial header fields; since exactly how headers should
143 // be implemented for server push is not well-understood, we
144 // are being conservative for now like httpd is:
145 // https://httpd.apache.org/docs/2.4/en/howto/http2.html#push
146 // we only copy some well-known, safe headers that are likely
147 // crucial when requesting certain kinds of content
148 for _, fieldName := range safeHeaders {
149 if vals, ok := r.Header[fieldName]; ok {
150 hdr[fieldName] = vals
151 }
152 }
153
154 // user can customize the push request headers
155 if h.Headers != nil {
156 h.Headers.ApplyTo(hdr, repl)
157 }
158
159 return hdr
160}
161
162// servePreloadLinks parses Link headers from upstream and pushes
163// resources described by them. If a resource has the "nopush"

Callers 1

ServeHTTPMethod · 0.95

Calls 2

ApplyToMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected