Goose authors, issue 4454 is fixed
David Cheney
david.cheney at canonical.com
Fri Nov 30 11:46:24 UTC 2012
SGTM.
One day I will write a http client that does either
a. does not require you to close the response body.
b. panics if you forget to close the response body.
Dave
On Friday, 30 November 2012 at 10:43 PM, John Arbash Meinel wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2012-11-30 12:04, David Cheney wrote:
> > http://code.google.com/p/go/issues/detail?id=4454
> >
> > Does this mean we need to revisit Tuesdays decision to use the
> > precise/quantal provided Go and move up to trunk ?
> >
> > Dave
>
> - From reading the description, it is trivial to work around the bug by
> calling req.Body.Close().
>
> Ie:
> func main() {
> go serve()
> for i := 0; i < 100; i++ {
> req, err := http.Get("http://localhost:1234/")
> if err != nil {
> fmt.Printf("req #%d: %s\n", i, err.Error())
> }
> req.Body.Close()
> }
> }
>
> I'm guessing the issue is that http is using connection pooling, and
> keep-alive on the connection objects. So it is leaving the socket in a
> bad state if you issue a second request.
>
> My guess is the other fix for it is:
> func handler(w http.ResponseWriter, r *http.Request) {
> w.Headers.Set("Content-Length", "0")
> w.WriteHeader(http.StatusNoContent)
> }
>
> So if:
>
> a) The server is telling the client there is no body
> b) The client is closing the request read cleanly.
>
> The go folks consider it to be a bug that you have to do (a) or (b),
> but I'm fine using one or both of them in our code. Both seem
> reasonably sanitary to do so.
>
> John
> =:->
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (Cygwin)
> Comment: Using GnuPG with undefined - http://www.enigmail.net/
>
> iEYEARECAAYFAlC4m9YACgkQJdeBCYSNAANlWwCeM5Utuv/KxbnIjZOa45E29S8j
> SGEAn31A2XFiKdXtivqgG2DDvQGFBHP2
> =ehfM
> -----END PGP SIGNATURE-----
More information about the Juju-dev
mailing list