cmd/go/internal/modfetch: wrap errors from HTTP response bodies
cmd/go/internal/modfetch: wrap errors from HTTP response bodies

The Read method on the Body returned from a net/http.Transport does
not wrap errors returned by the underlying io.Reader and returns a
bare io.ErrUnexpectedEOF if the body is shorter than the declared
Content-Length.

Since we can't feasibly add detail on the net/http side without
breaking established users, we must instead add detail on the caller
side. Since the net/http client uses url.Error for most of its own
errors, we use that same error type here.

I have not added a regression test for this change. (While it is
theoretically possible to set up a GOPROXY that returns incorrect
Content-Length headers, the change seems straightforward enough that
it isn't worth the complex test setup.)

Fixes #52727.

Change-Id: Id00b04ae4fd518148106a49188fe169aadbcce2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406675
Auto-Submit: Bryan Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
Run-TryBot: Bryan Mills <1c8aad60184261ccede67f5c63a0d2a3bf3c9ff4@google.com>
Reviewed-by: Michael Matloob <4562438b12c14e81a47550acde616ff328a909f8@golang.org>
TryBot-Result: Gopher Robot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>

nawawi/go,golang/go,nawawi/go,golang/go,golang/go,golang/go,nawawi/go,golang/go,golang/go,nawawi/go,golang/go,nawawi/go,golang/go,nawawi/go,nawawi/go,nawawi/go