Skip to content

Commit

Permalink
Stop retriable request from adding a non-nil Body (#726)
Browse files Browse the repository at this point in the history
When azure is responding with an error the retriable request that is generated ends up getting a non nil noOpcloser added to it with a reader interface. Ultimately this ends up sending a GET request to Azure that has a post body. As the http spec says that the body SHOULD be ignored this is not a critical error, but for people using custom transports this is problematic. It's also sending unessecary bytes.
  • Loading branch information
chrisst authored Sep 5, 2023
1 parent d3f8f8a commit df94ce5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autorest/retriablerequest_1.7.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type RetriableRequest struct {
func (rr *RetriableRequest) Prepare() (err error) {
// preserve the request body; this is to support retry logic as
// the underlying transport will always close the reqeust body
if rr.req.Body != nil {
if rr.req.Body != nil && rr.req.Body != http.NoBody {
if rr.br != nil {
_, err = rr.br.Seek(0, 0 /*io.SeekStart*/)
rr.req.Body = io.NopCloser(rr.br)
Expand Down
2 changes: 1 addition & 1 deletion autorest/retriablerequest_1.8.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type RetriableRequest struct {
func (rr *RetriableRequest) Prepare() (err error) {
// preserve the request body; this is to support retry logic as
// the underlying transport will always close the reqeust body
if rr.req.Body != nil {
if rr.req.Body != nil && rr.req.Body != http.NoBody {
if rr.rc != nil {
rr.req.Body = rr.rc
} else if rr.br != nil {
Expand Down

0 comments on commit df94ce5

Please sign in to comment.