mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 10:37:24 -04:00 
			
		
		
		
	gzip strips Accept-Encoding header after using it
This commit is contained in:
		
							parent
							
								
									7d46108c12
								
							
						
					
					
						commit
						dba4dcb4a5
					
				| @ -196,11 +196,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule) (map[string]string, error) | ||||
| 	for field, val := range r.Header { | ||||
| 		header := strings.ToUpper(field) | ||||
| 		header = headerNameReplacer.Replace(header) | ||||
| 		// We don't want to pass the encoding header to prevent the fastcgi server from gzipping | ||||
| 		// TODO: is there a better way. | ||||
| 		if header != "ACCEPT_ENCODING" { | ||||
| 			env["HTTP_"+header] = strings.Join(val, ", ") | ||||
| 		} | ||||
| 		env["HTTP_"+header] = strings.Join(val, ", ") | ||||
| 	} | ||||
| 
 | ||||
| 	return env, nil | ||||
|  | ||||
| @ -33,6 +33,9 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { | ||||
| 		return g.Next.ServeHTTP(w, r) | ||||
| 	} | ||||
| 
 | ||||
| 	// Delete this header so gzipping isn't repeated later in the chain | ||||
| 	r.Header.Del("Accept-Encoding") | ||||
| 
 | ||||
| 	w.Header().Set("Content-Encoding", "gzip") | ||||
| 	gzipWriter := gzip.NewWriter(w) | ||||
| 	defer gzipWriter.Close() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user