|
16 | 16 | package software.amazon.awssdk.awscore.eventstream;
|
17 | 17 |
|
18 | 18 | import static software.amazon.awssdk.core.http.HttpResponseHandler.X_AMZN_REQUEST_ID_HEADER;
|
| 19 | +import static software.amazon.awssdk.core.http.HttpResponseHandler.X_AMZ_ID_2_HEADER; |
19 | 20 | import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError;
|
20 | 21 |
|
21 | 22 | import java.io.ByteArrayInputStream;
|
@@ -156,6 +157,13 @@ public class EventStreamAsyncResponseTransformer<ResponseT, EventT>
|
156 | 157 | */
|
157 | 158 | private String requestId = null;
|
158 | 159 |
|
| 160 | + /** |
| 161 | + * Extended Request Id for the streaming request. The value is populated when the initial response is received from the |
| 162 | + * service. As request id is not sent in event messages (including exceptions), this can be returned by the SDK along with |
| 163 | + * received exception details. |
| 164 | + */ |
| 165 | + private String extendedRequestId = null; |
| 166 | + |
159 | 167 | @Deprecated
|
160 | 168 | @ReviewBeforeRelease("Remove this on full GA of 2.0.0")
|
161 | 169 | public EventStreamAsyncResponseTransformer(
|
@@ -194,6 +202,9 @@ public void responseReceived(SdkResponse response) {
|
194 | 202 | this.requestId = response.sdkHttpResponse()
|
195 | 203 | .firstMatchingHeader(X_AMZN_REQUEST_ID_HEADER)
|
196 | 204 | .orElse(null);
|
| 205 | + this.extendedRequestId = response.sdkHttpResponse() |
| 206 | + .firstMatchingHeader(X_AMZ_ID_2_HEADER) |
| 207 | + .orElse(null); |
197 | 208 | }
|
198 | 209 | }
|
199 | 210 |
|
@@ -324,6 +335,9 @@ private HttpResponse adaptMessageToResponse(Message m, boolean isException) {
|
324 | 335 | if (requestId != null) {
|
325 | 336 | response.addHeader(X_AMZN_REQUEST_ID_HEADER, requestId);
|
326 | 337 | }
|
| 338 | + if (extendedRequestId != null) { |
| 339 | + response.addHeader(X_AMZ_ID_2_HEADER, extendedRequestId); |
| 340 | + } |
327 | 341 |
|
328 | 342 | //TODO: fix the hard-coded status code
|
329 | 343 | response.setStatusCode(isException ? 500 : 200);
|
|
0 commit comments