transparency-dev / trillian-tessera

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

HTTP handlers: skip closing the body #209

Closed mhutchinson closed 2 months ago

mhutchinson commented 2 months ago

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

roger2hk commented 2 months 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 2 months 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 2 months ago

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

roger2hk commented 2 months ago

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

Found it, thanks!

image