Singleshot provides an http.RoundTripper
which deduplicates similar HTTP requests.
If two similar HTTP requests are supposed to be sent concurrently, the first one will actually be sent to the server, while the second one waits until the first one was fulfilled completely. The second request will never be sent to the server, but returns a copy of the response of the first request.
Req 1 -----------------> Resp 1
Req 2 ----> Resp 1'
Req 3 -------------> Resp 3
package main
import (
"net/http"
"go.eigsys.de/singleshot"
)
func main() {
_ = http.Client{
Transport: singleshot.NewTransport(http.DefaultTransport),
}
}
GET
and the request must not be a range
request. The body is ignored according to RFC 2616, section 9.3.See GoDoc.