Keep compatibility with Go 1.13.14. (#264)
* - Keep compliance with Golang 1.13.14. http.Header has no method Values on older go versions. * Do not return error when client request id is missing
This commit is contained in:
Родитель
b0f228e10f
Коммит
5e5d32824b
|
@ -3,6 +3,7 @@ package azblob
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/Azure/azure-pipeline-go/pipeline"
|
||||
)
|
||||
|
||||
|
@ -21,11 +22,9 @@ func NewUniqueRequestIDPolicyFactory() pipeline.Factory {
|
|||
resp, err := next.Do(ctx, request)
|
||||
|
||||
if err == nil && resp != nil {
|
||||
val := resp.Response().Header.Values(xMsClientRequestID)
|
||||
if len(val) > 0 {
|
||||
if val[0] != id {
|
||||
err = errors.New("client Request ID from request and response does not match")
|
||||
}
|
||||
crId := resp.Response().Header.Get(xMsClientRequestID)
|
||||
if crId != "" && crId != id {
|
||||
err = errors.New("client Request ID from request and response does not match")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ package azblob
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/Azure/azure-pipeline-go/pipeline"
|
||||
chk "gopkg.in/check.v1"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/Azure/azure-pipeline-go/pipeline"
|
||||
chk "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
type requestIDTestScenario int
|
||||
|
@ -58,7 +59,7 @@ func (s *aztestsSuite) TestEchoClientRequestIDMissing(c *chk.C) {
|
|||
|
||||
c.Assert(err, chk.IsNil)
|
||||
c.Assert(resp, chk.NotNil)
|
||||
c.Assert(resp.Response().Header.Values(xMsClientRequestID), chk.IsNil)
|
||||
c.Assert(resp.Response().Header.Get(xMsClientRequestID), chk.Equals, "")
|
||||
}
|
||||
|
||||
func (s *aztestsSuite) TestEchoClientRequestIDErrorFromNextPolicy(c *chk.C) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче