@@ -18,6 +18,27 @@ func TestUtils(t *testing.T) {
1818 assert .Equal (t , "https://example.com/test?q=1" , GetFullURL (req ))
1919 })
2020
21+ t .Run ("isHTTPS" , func (t * testing.T ) {
22+ check := func (header , value string ) bool {
23+ h := http.Header {}
24+ h .Set (header , value )
25+ return isHTTPS (h )
26+ }
27+ assert .True (t , check ("X-Forwarded-Proto" , "https" ))
28+ assert .True (t , check ("X-Forwarded-Proto" , "https, http" ))
29+ assert .False (t , check ("X-Forwarded-Proto" , "http" ))
30+ assert .True (t , check ("X-Forwarded-Protocol" , "https" ))
31+ assert .True (t , check ("X-Forwarded-Scheme" , "https" ))
32+ assert .True (t , check ("X-Url-Scheme" , "https" ))
33+ assert .True (t , check ("X-Scheme" , "https" ))
34+ assert .True (t , check ("Forwarded" , "for=192.0.2.1;proto=https;host=example.com" ))
35+ assert .True (t , check ("Forwarded" , "proto=\" https\" " ))
36+ assert .False (t , check ("Forwarded" , "for=192.0.2.1;proto=http" ))
37+ assert .True (t , check ("Front-End-Https" , "on" ))
38+ assert .True (t , check ("X-Forwarded-Ssl" , "on" ))
39+ assert .False (t , isHTTPS (http.Header {}))
40+ })
41+
2142 t .Run ("ParseContentLength" , func (t * testing.T ) {
2243 assert .Equal (t , int64 (- 1 ), ParseContentLength ("" ))
2344 assert .Equal (t , int64 (- 1 ), ParseContentLength ("invalid" ))
0 commit comments