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

Remove unnecessary header field in ErrorResponse #1066

Merged
merged 1 commit into from Jan 23, 2019
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
8 changes: 2 additions & 6 deletions api-error-response.go
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
11 changes: 10 additions & 1 deletion api-error-response_test.go
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
}
}