]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/aws/aws-sdk-go/aws/request/request_1_7.go
869b97a1a0fa7c7623d6f99d2d9b2e528d8f48e4
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / request / request_1_7.go
1 // +build !go1.8
2
3 package request
4
5 import "io"
6
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.
11 //
12 // Copy of Go 1.8 NoBody type from net/http/http.go
13 type noBody struct{}
14
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 }
18
19 // NoBody is an empty reader that will trigger the Go HTTP client to not include
20 // and body in the HTTP request.
21 var NoBody = noBody{}
22
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.
26 //
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
30 // call ResetBody.
31 func (r *Request) ResetBody() {
32 body, err := r.getNextRequestBody()
33 if err != nil {
34 r.Error = err
35 return
36 }
37
38 r.HTTPRequest.Body = body
39 }