I took another look at this and realized what I'd gotten wrong: each Request given to CheckRedirect, including req and each of via, has a nested Response that caused the request, *not* the response to that request, as I had assumed. This is mentioned in the documentation:
// Response is the redirect response which caused this request // to be created. This field is only populated during client // redirects. So the response to via[0] (first redirect) is via[1].Response, and the response to via[len(via)-1] (last redirect) is req.Response. On Fri, Nov 16, 2018 at 7:43 PM Caleb Spare <cesp...@gmail.com> wrote: > > It seems like http.Client's CheckRedirect hook only populates the > via[n].Response for n>0 (i.e., not for the first hop). This is useful if, for > instance, you want to check the status code (301, 302, etc) of each redirect. > > Here's a playground demo: https://play.golang.org/p/cKoWVhdjKwf > > I can file an issue, but I feel like I'm missing something, because this is > the most obvious thing to want to do with CheckRedirect and nobody else seems > to have complained about it. Can someone clue me in? > > Caleb -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.