| 134 | } |
| 135 | |
| 136 | func (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" |