weaveworks / common

Libraries used in multiple Weave projects
Other
129 stars 92 forks source link

Add Unwrap method to http.ResponseWriter implementations. #283

Closed pstibrany closed 1 year ago

pstibrany commented 1 year ago

This PR adds Unwrap method to all implementations of http.ResponseWriter.

New https://pkg.go.dev/net/http#ResponseController introduced in Go 1.20 uses Unwrap method to get access to original http.ResponseWriter or underlying connection.

My use case: I'd like to use http.ResponseController to set longer timeouts on HTTP endpoints for uploading big files, overriding global -server.http-write-timeout and -server.http-read-timeout.

This PR also updates httpsnoop library to version 1.0.3, which supports Unwrap method as well (since 1.0.2) (https://github.com/felixge/httpsnoop/issues/8).

(To make weaveworks/common fully compatible with new http.ResponseController, opentracing-contrib/go-stdlib library needs an update too, after https://github.com/opentracing-contrib/go-stdlib/pull/68 is merged).