diff --git a/api-error-response.go b/api-error-response.go index 655991cff..0170b8de8 100644 --- a/api-error-response.go +++ b/api-error-response.go @@ -36,6 +36,8 @@ import ( */ // ErrorResponse - Is the typed error returned by all API operations. +// ErrorResponse struct should be comparable since it is compared inside +// golang http API (https://github.com/golang/go/issues/29768) type ErrorResponse struct { XMLName xml.Name `xml:"Error" json:"-"` Code string @@ -51,9 +53,6 @@ type ErrorResponse struct { // Underlying HTTP status code for the returned error StatusCode int `xml:"-" json:"-"` - - // Headers of the returned S3 XML error - Headers http.Header `xml:"-" json:"-"` } // ToErrorResponse - Returns parsed ErrorResponse struct from body and @@ -177,9 +176,6 @@ func httpRespToErrorResponse(resp *http.Response, bucketName, objectName string) errResp.Message = fmt.Sprintf("Region does not match, expecting region ā€˜%sā€™.", errResp.Region) } - // Save headers returned in the API XML error - errResp.Headers = resp.Header - return errResp } diff --git a/api-error-response_test.go b/api-error-response_test.go index bf10941b4..353103bdd 100644 --- a/api-error-response_test.go +++ b/api-error-response_test.go @@ -77,7 +77,6 @@ func TestHttpRespToErrorResponse(t *testing.T) { RequestID: resp.Header.Get("x-amz-request-id"), HostID: resp.Header.Get("x-amz-id-2"), Region: resp.Header.Get("x-amz-bucket-region"), - Headers: resp.Header, } return errResp } @@ -292,3 +291,13 @@ func TestErrWithoutMessage(t *testing.T) { t.Errorf("Expected \"Error response code InvalidArgument.\", got %s", errResp) } } + +// Tests if ErrorResponse is comparable since it is compared +// inside golang http code (https://github.com/golang/go/issues/29768) +func TestErrorResponseComparable(t *testing.T) { + var e1 interface{} = ErrorResponse{} + var e2 interface{} = ErrorResponse{} + if e1 != e2 { + t.Fatalf("ErrorResponse should be comparable") + } +}