Now, i do something like this with Golang:
//read all bytes from body
bytes, err := ioutil.ReadAll(request.Body)
//set the bytes as NewReader to new request.body
request, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(bytes))
but i want to streaming read from original body(io.Reader) to the new, instead of read all bytes to memory by ReadAll,and then copy to NewRequest.
How can i implement this?
thx.
Check the io
package if you want specialized reader - writer handling, the Pipe or Tee structs might be useful.
In this case, though,
request, err := http.NewRequest(http.MethodPut, url, request.Body)
should actually just work fine.