@@ -1237,6 +1237,43 @@ func TestSSLForceHostTemporaryRedirect(t *testing.T) {
1237
1237
expect (t , res .Code , http .StatusTemporaryRedirect )
1238
1238
}
1239
1239
1240
+ func TestModifyResponseHeadersNoSSL (t * testing.T ) {
1241
+ s := New (Options {
1242
+ SSLRedirect : false ,
1243
+ })
1244
+
1245
+ res := & http.Response {}
1246
+ res .Header = http.Header {"Location" : []string {"http://example.com" }}
1247
+
1248
+ err := s .ModifyResponseHeaders (res )
1249
+ expect (t , err , nil )
1250
+
1251
+ expect (t , res .Header .Get ("Location" ), "http://example.com" )
1252
+ }
1253
+
1254
+ func TestModifyResponseHeadersWithSSL (t * testing.T ) {
1255
+ s := New (Options {
1256
+ SSLRedirect : true ,
1257
+ SSLProxyHeaders : map [string ]string {"X-Forwarded-Proto" : "https" },
1258
+ })
1259
+
1260
+ req , _ := http .NewRequest ("GET" , "/foo" , nil )
1261
+ req .Host = "www.example.com"
1262
+ req .URL .Scheme = "http"
1263
+ req .Header .Add ("X-Forwarded-Proto" , "https" )
1264
+
1265
+ res := & http.Response {}
1266
+ res .Header = http.Header {"Location" : []string {"http://example.com" }}
1267
+ res .Request = req
1268
+
1269
+ expect (t , res .Header .Get ("Location" ), "http://example.com" )
1270
+
1271
+ err := s .ModifyResponseHeaders (res )
1272
+ expect (t , err , nil )
1273
+
1274
+ expect (t , res .Header .Get ("Location" ), "https://example.com" )
1275
+ }
1276
+
1240
1277
/* Test Helpers */
1241
1278
func expect (t * testing.T , a interface {}, b interface {}) {
1242
1279
if a != b {
0 commit comments