1
2
3
4
5
6
7
8
9
10 package httpguts
11
12 import (
13 "net/textproto"
14 "strings"
15 )
16
17
18
19
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 }
51
View as plain text