-
Notifications
You must be signed in to change notification settings - Fork 644
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
AWS S3: make raw request URI contain path and query #1923
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
val rawPath = uri.path.toString() | ||
|
||
if (rawPath.contains("+")) { | ||
val fixedPath = rawPath.replaceAll("\\+", "%2B") | ||
|
||
rawUri.replace(rawPath, fixedPath) | ||
fixedPath + rawUri.drop(rawPath.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, under assumption that the rawUri
now starts with the path which should be case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a require(rawUri startsWith rawPath)
just to make sure there are no surprises later on?
@@ -185,7 +185,7 @@ class HttpRequestsSpec extends FlatSpec with Matchers with ScalaFutures { | |||
val req = HttpRequests.getDownloadRequest(location) | |||
req.uri.authority.host.toString shouldEqual "bucket.s3.amazonaws.com" | |||
req.uri.path.toString shouldEqual "/test%20folder/1%20+%202%20=%203" | |||
req.headers should contain(`Raw-Request-URI`("https://bucket.s3.amazonaws.com/test%20folder/1%20%2B%202%20=%203")) | |||
req.headers should contain(`Raw-Request-URI`("/test%20folder/1%20%2B%202%20=%203")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -185,7 +185,7 @@ class HttpRequestsSpec extends FlatSpec with Matchers with ScalaFutures { | |||
val req = HttpRequests.getDownloadRequest(location) | |||
req.uri.authority.host.toString shouldEqual "bucket.s3.amazonaws.com" | |||
req.uri.path.toString shouldEqual "/test%20folder/1%20+%202%20=%203" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion is a bit useless as it isn't used when Raw-Request-URI
is set but it also doesn't hurt to show the distinction here.
* make raw request URI contains path and query * Shut down actor systems in tests
[Backport #1923] AWS S3: make raw request URI contains path and query
Backported to 1.1.x with #1963 |
Purpose
Just pass the URI path and query as
Raw-Request-URI
so that Amazon S3 understands Alpakka's HTTP requests.References
Reported in #1919
akka/akka-http#451
#1738
#838
Changes
Background Context
As Amazon S3's use of HTTP is non-standard the fix in #1738 introduced a new problem. Originally discussed in akka/akka-http#451 the Raw Request URI needs to be without request scheme and authority.