Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: make Transport use GetBody, retry requests when no bytes were written #18241
I'm not convinced about GetBody as an abstraction - it's not natural when using some kinds of obviously-retriable bodies such as files. Why not just seek to the body start if it implements io.Seeker? (you'd probably want to make that behaviour opt-in rather than opt-out).
But since you need an opt-in anyway, this seems like a reasonable opt-in. And we can't change our previous Close behavior, so seeking back to the beginning of a closed file obviously isn't going to work. Plus the more experience I have with type sniffing magic, the more it bites me. I like the explicitness of GetBody. GetBody is not just for Transport retries on network failures, but also Client redirects, replaying the request body. Trying to reuse the same Body while coordinating across those two layers (not forgetting http2) and without adding new API surface seems like it'd be gross.
I'm not sure this is the best place to discuss GetBody, though.