transparency-dev / trillian-tessera

Go library for building tile-based transparency logs (tlogs)
Apache License 2.0
10 stars 10 forks source link

HTTP handlers: skip closing the body #209

Closed mhutchinson closed 1 month ago

mhutchinson commented 1 month ago

From Request.Body docs: The Server will close the request body. The ServeHTTP Handler does not need to.

roger2hk commented 1 month ago

This is true when the body is fully read. Does the body need to be closed when the io.ReadAll returns an error?

mhutchinson commented 1 month ago

The contract doesn't say anything about that: https://pkg.go.dev/net/http#Request (you need to scroll down a bit to get to Body, and there's no way to link to the field members for some reason)

mhutchinson commented 1 month ago

Note that the contract is different on the http client request. That body does need to be closed. Carefully.

roger2hk commented 1 month ago

Note that the contract is different on the http client request. That body does need to be closed. Carefully.

Found it, thanks!

image