--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Depends what you want to re-use the request for. If you just want to store it for matching with the response, might be worth looking at:Have a read of http://golang.org/pkg/net/http/httputil/#DumpRequest
In the past I've done this by using a custom reader for Body which
reads from a shared (fixed) buffer. I copy the request and then swap
out the body for a new one.
https://github.com/cespare/steller/blob/master/steller.go#L28-L53
https://github.com/cespare/steller/blob/master/steller.go#L154-L155
Is the use case that you want to be able to dynamically alter the body of some future Requests while some Requests are in flight?
> No. I don't want to alter the body at all. I just want to either be able to use the same http.Request concurrently (which I can't) or to be able to copy an http.Request in its integrity.Well a Request has state, such as the Content-Length header based on the size of the given body, so this is probably never going to work. Why are you trying to reuse requests when they are cheap to make? If you want huge bodies, just re-use the reader and build new requests on demand. Your race is probably happening here:
https://github.com/tsenart/vegeta/blob/request-body/lib/targets.go#L83
Perhaps the docs should point out that the Request struct fields aren't settable:
http://golang.org/src/pkg/net/http/request.go#L118
If you changed your API to be func NewTargets(lines []string, body io.ReadCloser, header http.Header) (Targets, error)
https://github.com/tsenart/vegeta/blob/request-body/lib/targets.go#L37