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

Method servePreloadLinks

modules/caddyhttp/push/handler.go:166–183  ·  view source on GitHub ↗

servePreloadLinks parses Link headers from upstream and pushes resources described by them. If a resource has the "nopush" attribute or describes an external entity (meaning, the resource URI includes a scheme), it will not be pushed.

(pusher http.Pusher, hdr http.Header, resources []string)

Source from the content-addressed store, hash-verified

164// attribute or describes an external entity (meaning, the resource
165// URI includes a scheme), it will not be pushed.
166func (h Handler) servePreloadLinks(pusher http.Pusher, hdr http.Header, resources []string) {
167 for _, resource := range resources {
168 for _, resource := range parseLinkHeader(resource) {
169 if _, ok := resource.params["nopush"]; ok {
170 continue
171 }
172 if isRemoteResource(resource.uri) {
173 continue
174 }
175 err := pusher.Push(resource.uri, &http.PushOptions{
176 Header: hdr,
177 })
178 if err != nil {
179 return
180 }
181 }
182 }
183}
184
185// Resource represents a request for a resource to push.
186type Resource struct {

Callers 1

WriteHeaderMethod · 0.80

Calls 3

parseLinkHeaderFunction · 0.85
isRemoteResourceFunction · 0.85
PushMethod · 0.80

Tested by

no test coverage detected