|
17 | 17 |
|
18 | 18 | import java.nio.ByteBuffer; |
19 | 19 | import java.nio.file.Path; |
20 | | -import java.util.List; |
21 | 20 | import java.util.Optional; |
22 | 21 | import java.util.concurrent.CompletableFuture; |
23 | 22 | import java.util.concurrent.atomic.AtomicBoolean; |
|
28 | 27 | import software.amazon.awssdk.core.SdkResponse; |
29 | 28 | import software.amazon.awssdk.core.async.AsyncResponseTransformer; |
30 | 29 | import software.amazon.awssdk.core.async.SdkPublisher; |
31 | | -import software.amazon.awssdk.utils.CollectionUtils; |
32 | 30 | import software.amazon.awssdk.utils.CompletableFutureUtils; |
33 | 31 | import software.amazon.awssdk.utils.ContentRangeParser; |
34 | 32 | import software.amazon.awssdk.utils.Logger; |
35 | 33 | import software.amazon.awssdk.utils.Pair; |
36 | | -import software.amazon.awssdk.utils.StringUtils; |
37 | 34 | import software.amazon.awssdk.utils.Validate; |
38 | 35 |
|
39 | 36 | /** |
@@ -107,15 +104,15 @@ public CompletableFuture<T> prepare() { |
107 | 104 |
|
108 | 105 | @Override |
109 | 106 | public void onResponse(T response) { |
110 | | - List<String> contentRangeList = response.sdkHttpResponse().headers().get("x-amz-content-range"); |
111 | | - if (CollectionUtils.isNullOrEmpty(contentRangeList) || StringUtils.isEmpty(contentRangeList.get(0))) { |
| 107 | + Optional<String> contentRangeList = response.sdkHttpResponse().firstMatchingHeader("x-amz-content-range"); |
| 108 | + if (!contentRangeList.isPresent()) { |
112 | 109 | if (subscriber != null) { |
113 | 110 | subscriber.onError(new IllegalStateException("Content range header is missing")); |
114 | 111 | } |
115 | 112 | return; |
116 | 113 | } |
117 | 114 |
|
118 | | - String contentRange = contentRangeList.get(0); |
| 115 | + String contentRange = contentRangeList.get(); |
119 | 116 | Optional<Pair<Long, Long>> contentRangePair = ContentRangeParser.range(contentRange); |
120 | 117 | if (!contentRangePair.isPresent()) { |
121 | 118 | if (subscriber != null) { |
|
0 commit comments