SameHostRedirectPolicy allows redirect only if the redirected host is the same as original host, e.g. redirect to "www.imroc.cc" from "imroc.cc" is not the allowed.
()
| 49 | // is the same as original host, e.g. redirect to "www.imroc.cc" from |
| 50 | // "imroc.cc" is not the allowed. |
| 51 | func SameHostRedirectPolicy() RedirectPolicy { |
| 52 | return func(req *http.Request, via []*http.Request) error { |
| 53 | if getHostname(req.URL.Host) != getHostname(via[0].URL.Host) { |
| 54 | return errors.New("different host name is not allowed") |
| 55 | } |
| 56 | return nil |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // AllowedHostRedirectPolicy allows redirect only if the redirected host |
| 61 | // match one of the host that specified. |
searching dependent graphs…