Goose authors, issue 4454 is fixed
John Arbash Meinel
john at arbash-meinel.com
Fri Nov 30 11:43:19 UTC 2012
-----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