@@ -116,16 +116,23 @@ func TestClientRedirectPolicy(t *testing.T) {
116116 defer ts .Close ()
117117
118118 c := dcnl ().SetRedirectPolicy (FlexibleRedirectPolicy (20 ), DomainCheckRedirectPolicy ("127.0.0.1" ))
119- _ , err := c .R ().
119+ res , err := c .R ().
120120 SetHeader ("Name1" , "Value1" ).
121121 SetHeader ("Name2" , "Value2" ).
122122 SetHeader ("Name3" , "Value3" ).
123123 Get (ts .URL + "/redirect-1" )
124124
125125 assertEqual (t , true , err .Error () == "Get \" /redirect-21\" : resty: stopped after 20 redirects" )
126126
127+ redirects := res .RedirectHistory ()
128+ assertEqual (t , 20 , len (redirects ))
129+
130+ finalReq := redirects [0 ]
131+ assertEqual (t , 307 , finalReq .StatusCode )
132+ assertEqual (t , ts .URL + "/redirect-20" , finalReq .URL )
133+
127134 c .SetRedirectPolicy (NoRedirectPolicy ())
128- res , err : = c .R ().Get (ts .URL + "/redirect-1" )
135+ res , err = c .R ().Get (ts .URL + "/redirect-1" )
129136 assertNil (t , err )
130137 assertEqual (t , http .StatusTemporaryRedirect , res .StatusCode ())
131138 assertEqual (t , `<a href="/redirect-2">Temporary Redirect</a>.` , res .String ())
0 commit comments