| 210 | } |
| 211 | |
| 212 | func (lp linkPusher) WriteHeader(statusCode int) { |
| 213 | if links, ok := lp.ResponseWriter.Header()["Link"]; ok { |
| 214 | // only initiate these pushes if it hasn't been done yet |
| 215 | if val := caddyhttp.GetVar(lp.request.Context(), pushedLink); val == nil { |
| 216 | if c := lp.handler.logger.Check(zapcore.DebugLevel, "pushing Link resources"); c != nil { |
| 217 | c.Write(zap.Strings("linked", links)) |
| 218 | } |
| 219 | caddyhttp.SetVar(lp.request.Context(), pushedLink, true) |
| 220 | lp.handler.servePreloadLinks(lp.pusher, lp.header, links) |
| 221 | } |
| 222 | } |
| 223 | lp.ResponseWriter.WriteHeader(statusCode) |
| 224 | } |
| 225 | |
| 226 | // isRemoteResource returns true if resource starts with |
| 227 | // a scheme or is a protocol-relative URI. |