Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: adding body back to response #13701

Merged
merged 5 commits into from Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/armcore/go.mod
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
@@ -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
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