github.com/aavshr/aws-sdk-go@v1.41.3/aws/request/request_1_8.go (about) 1 //go:build go1.8 2 // +build go1.8 3 4 package request 5 6 import ( 7 "net/http" 8 9 "github.com/aavshr/aws-sdk-go/aws/awserr" 10 ) 11 12 // NoBody is a http.NoBody reader instructing Go HTTP client to not include 13 // and body in the HTTP request. 14 var NoBody = http.NoBody 15 16 // ResetBody rewinds the request body back to its starting position, and 17 // sets the HTTP Request body reference. When the body is read prior 18 // to being sent in the HTTP request it will need to be rewound. 19 // 20 // ResetBody will automatically be called by the SDK's build handler, but if 21 // the request is being used directly ResetBody must be called before the request 22 // is Sent. SetStringBody, SetBufferBody, and SetReaderBody will automatically 23 // call ResetBody. 24 // 25 // Will also set the Go 1.8's http.Request.GetBody member to allow retrying 26 // PUT/POST redirects. 27 func (r *Request) ResetBody() { 28 body, err := r.getNextRequestBody() 29 if err != nil { 30 r.Error = awserr.New(ErrCodeSerialization, 31 "failed to reset request body", err) 32 return 33 } 34 35 r.HTTPRequest.Body = body 36 r.HTTPRequest.GetBody = r.getNextRequestBody 37 }