github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/golang.org/x/net/http/httpguts/guts.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package httpguts provides functions implementing various details 6 // of the HTTP specification. 7 // 8 // This package is shared by the standard library (which vendors it) 9 // and x/net/http2. It comes with no API stability promise. 10 package httpguts 11 12 import ( 13 "net/textproto" 14 "strings" 15 ) 16 17 // ValidTrailerHeader reports whether name is a valid header field name to appear 18 // in trailers. 19 // See RFC 7230, Section 4.1.2 20 func ValidTrailerHeader(name string) bool { 21 name = textproto.CanonicalMIMEHeaderKey(name) 22 if strings.HasPrefix(name, "If-") || badTrailer[name] { 23 return false 24 } 25 return true 26 } 27 28 var badTrailer = map[string]bool{ 29 "Authorization": true, 30 "Cache-Control": true, 31 "Connection": true, 32 "Content-Encoding": true, 33 "Content-Length": true, 34 "Content-Range": true, 35 "Content-Type": true, 36 "Expect": true, 37 "Host": true, 38 "Keep-Alive": true, 39 "Max-Forwards": true, 40 "Pragma": true, 41 "Proxy-Authenticate": true, 42 "Proxy-Authorization": true, 43 "Proxy-Connection": true, 44 "Range": true, 45 "Realm": true, 46 "Te": true, 47 "Trailer": true, 48 "Transfer-Encoding": true, 49 "Www-Authenticate": true, 50 }