forked from aws/aws-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
private/protocol/rest: Use RawPath instead of Opaque (aws#993)
It was discovered the bug golang/go#16847 prevents usage of AWS services using HTTP 2, such as AWS X-Ray with the AWS SDK for Go because Go 1.6.2 - 1.7.4 does not correctly build HTTP2 request when the URL uses Opaque to set the escaped version of the URL path. This has been fixed int he Go 1.8 branch, but this change will ensure users using the current version of Go will be able to connect to AWS services using HTTP2. With this change the SDK will no longer with with the unsupported Go version 1.4.
- Loading branch information
Showing
9 changed files
with
105 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,63 @@ | ||
package rest | ||
|
||
import ( | ||
"net/http" | ||
"net/url" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/request" | ||
) | ||
|
||
func TestUpdatePathWithRaw(t *testing.T) { | ||
func TestCleanPath(t *testing.T) { | ||
uri := &url.URL{ | ||
Path: "//foo//bar", | ||
Scheme: "https", | ||
Host: "host", | ||
} | ||
updatePath(uri, "//foo//bar", true) | ||
cleanPath(uri) | ||
|
||
expected := "https://host//foo//bar" | ||
assert.Equal(t, expected, uri.String()) | ||
expected := "https://host/foo/bar" | ||
if a, e := uri.String(), expected; a != e { | ||
t.Errorf("expect %q URI, got %q", e, a) | ||
} | ||
} | ||
|
||
func TestUpdatePathNoRaw(t *testing.T) { | ||
uri := &url.URL{ | ||
Scheme: "https", | ||
Host: "host", | ||
func TestMarshalPath(t *testing.T) { | ||
in := struct { | ||
Bucket *string `location:"uri" locationName:"bucket"` | ||
Key *string `location:"uri" locationName:"key"` | ||
}{ | ||
Bucket: aws.String("mybucket"), | ||
Key: aws.String("my/cool+thing space/object世界"), | ||
} | ||
|
||
expectURL := `/mybucket/my/cool+thing space/object世界` | ||
expectEscapedURL := `/mybucket/my/cool%2Bthing%20space/object%E4%B8%96%E7%95%8C` | ||
|
||
req := &request.Request{ | ||
HTTPRequest: &http.Request{ | ||
URL: &url.URL{Scheme: "https", Host: "exmaple.com", Path: "/{bucket}/{key+}"}, | ||
}, | ||
Params: &in, | ||
} | ||
|
||
Build(req) | ||
|
||
if req.Error != nil { | ||
t.Fatalf("unexpected error, %v", req.Error) | ||
} | ||
|
||
if a, e := req.HTTPRequest.URL.Path, expectURL; a != e { | ||
t.Errorf("expect %q URI, got %q", e, a) | ||
} | ||
|
||
if a, e := req.HTTPRequest.URL.RawPath, expectEscapedURL; a != e { | ||
t.Errorf("expect %q escaped URI, got %q", e, a) | ||
} | ||
|
||
if a, e := req.HTTPRequest.URL.EscapedPath(), expectEscapedURL; a != e { | ||
t.Errorf("expect %q escaped URI, got %q", e, a) | ||
} | ||
updatePath(uri, "//foo//bar", false) | ||
|
||
expected := "https://host/foo/bar" | ||
assert.Equal(t, expected, uri.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters