|
5 | 5 | import io.reactiverse.awssdk.reactivestreams.ReadStreamPublisher;
|
6 | 6 | import io.vertx.core.Context;
|
7 | 7 | import io.vertx.core.Vertx;
|
8 |
| -import io.vertx.core.http.*; |
| 8 | +import io.vertx.core.http.HttpClient; |
| 9 | +import io.vertx.core.http.HttpClientOptions; |
| 10 | +import io.vertx.core.http.HttpClientRequest; |
| 11 | +import io.vertx.core.http.HttpHeaders; |
| 12 | +import io.vertx.core.http.HttpMethod; |
| 13 | +import io.vertx.core.http.RequestOptions; |
9 | 14 | import software.amazon.awssdk.http.SdkHttpFullResponse;
|
10 | 15 | import software.amazon.awssdk.http.SdkHttpRequest;
|
11 | 16 | import software.amazon.awssdk.http.SdkHttpResponse;
|
12 | 17 | import software.amazon.awssdk.http.async.AsyncExecuteRequest;
|
13 | 18 | import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
|
14 | 19 | import software.amazon.awssdk.http.async.SdkAsyncHttpResponseHandler;
|
15 | 20 | import software.amazon.awssdk.http.async.SdkHttpContentPublisher;
|
| 21 | +import software.amazon.awssdk.utils.StringUtils; |
16 | 22 |
|
17 |
| -import java.util.Optional; |
| 23 | +import java.net.URI; |
18 | 24 | import java.util.concurrent.CompletableFuture;
|
19 | 25 |
|
20 | 26 | import static java.util.Objects.requireNonNull;
|
@@ -90,13 +96,21 @@ void executeOnContext(AsyncExecuteRequest asyncExecuteRequest, CompletableFuture
|
90 | 96 | }
|
91 | 97 | }
|
92 | 98 |
|
93 |
| - private static RequestOptions getRequestOptions(SdkHttpRequest request) { |
94 |
| - return new RequestOptions() |
95 |
| - .setHost(request.host()) |
96 |
| - .setPort(request.port()) |
97 |
| - .setURI(request.encodedPath()) |
98 |
| - .setSsl("https".equals(request.protocol())); |
99 |
| - } |
| 99 | + private static RequestOptions getRequestOptions(SdkHttpRequest request) { |
| 100 | + return new RequestOptions() |
| 101 | + .setHost(request.host()) |
| 102 | + .setPort(request.port()) |
| 103 | + .setURI(createRelativeUri(request.getUri())) |
| 104 | + .setSsl("https".equals(request.protocol())); |
| 105 | + } |
| 106 | + |
| 107 | + private static String createRelativeUri(URI uri) { |
| 108 | + return (StringUtils.isEmpty(uri.getPath()) ? "/" : uri.getPath()) + |
| 109 | + // AWS requires query parameters to be encoded as defined by RFC 3986. |
| 110 | + // see https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html |
| 111 | + // uri.toASCIIString() returns the URI encoded in this manner |
| 112 | + (StringUtils.isEmpty(uri.getQuery()) ? "" : "?" + uri.toASCIIString().split("\\?")[1]); |
| 113 | + } |
100 | 114 |
|
101 | 115 | @Override
|
102 | 116 | public void close() {
|
|
0 commit comments