7 // NoBody is an io.ReadCloser with no bytes. Read always returns EOF
8 // and Close always returns nil. It can be used in an outgoing client
9 // request to explicitly signal that a request has zero bytes.
10 // An alternative, however, is to simply set Request.Body to nil.
12 // Copy of Go 1.8 NoBody type from net/http/http.go
15 func (noBody) Read([]byte) (int, error) { return 0, io.EOF }
16 func (noBody) Close() error { return nil }
17 func (noBody) WriteTo(io.Writer) (int64, error) { return 0, nil }
19 // NoBody is an empty reader that will trigger the Go HTTP client to not include
20 // and body in the HTTP request.
23 // ResetBody rewinds the request body back to its starting position, and
24 // set's the HTTP Request body reference. When the body is read prior
25 // to being sent in the HTTP request it will need to be rewound.
27 // ResetBody will automatically be called by the SDK's build handler, but if
28 // the request is being used directly ResetBody must be called before the request
29 // is Sent. SetStringBody, SetBufferBody, and SetReaderBody will automatically
31 func (r *Request) ResetBody() {
32 body, err := r.getNextRequestBody()
38 r.HTTPRequest.Body = body