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)
| 164 | // attribute or describes an external entity (meaning, the resource |
| 165 | // URI includes a scheme), it will not be pushed. |
| 166 | func (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. |
| 186 | type Resource struct { |
no test coverage detected