Skip to content

Commit

Permalink
Bug fix: adding body back to response (#13701)
Browse files Browse the repository at this point in the history
* adding body back to response

* Adding azcore dependant seek for body

* updating azcore version

* undo azcore version.go change

* assign Seek error to poller
  • Loading branch information
catalinaperalta authored Nov 20, 2020
1 parent c1bff18 commit ab95038
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdk/armcore/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/Azure/azure-sdk-for-go/sdk/armcore
go 1.14

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0
)
4 changes: 2 additions & 2 deletions sdk/armcore/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1 h1:YLBIWApuKB/RS0dK/mk/2g6x2+kjI9djMKqViZDTD88=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3 h1:Q/fMaKaJfKuwlQNELa2ttHS3zzn0KXf43HmrvAYRxMY=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.3/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0 h1:HG1ggl8L3ZkV/Ydanf7lKr5kkhhPGCpWdnr1J6v7cO4=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
13 changes: 13 additions & 0 deletions sdk/armcore/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
package armcore

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -452,6 +454,17 @@ func (pt *pollingTrackerBase) updateRawBody() error {
pt.Err = err
return pt.Err
}
// seek back to the beginning of the body or reassign the information to the body
if seeker, ok := pt.resp.Body.(io.Seeker); ok {
_, err = seeker.Seek(0, io.SeekStart)
if err != nil {
pt.Err = err
return pt.Err
}
} else {
// put the body back so it's available to other callers
pt.resp.Body = ioutil.NopCloser(bytes.NewReader(b))
}
// observed in 204 responses over HTTP/2.0; the content length is -1 but body is empty
if len(b) == 0 {
return nil
Expand Down

0 comments on commit ab95038

Please sign in to comment.