The Client of the http package contains the CheckRedirect field. The field is a function that has the req and via parameters. req is the upcoming request and via refers to the previous requests. This way, you can modify the request after the redirect. In the previous example, the Known-redirects header is modified.
In case the CheckRedirect function returns the error, the last response with a closed body accompanied with a wrapped error is returned. In case the http.ErrUseLastResponse is returned, the last response is returned, but the body is not closed so it is possible to read it.