Java Code Examples for software.amazon.awssdk.http.AbortableInputStream#create()
The following examples show how to use
software.amazon.awssdk.http.AbortableInputStream#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UrlConnectionHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Override public HttpExecuteResponse call() throws IOException { connection.connect(); request.contentStreamProvider().ifPresent(provider -> invokeSafely(() -> IoUtils.copy(provider.newStream(), connection.getOutputStream()))); int responseCode = connection.getResponseCode(); boolean isErrorResponse = HttpStatusFamily.of(responseCode).isOneOf(CLIENT_ERROR, SERVER_ERROR); InputStream content = !isErrorResponse ? connection.getInputStream() : connection.getErrorStream(); AbortableInputStream responseBody = content != null ? AbortableInputStream.create(content) : null; return HttpExecuteResponse.builder() .response(SdkHttpResponse.builder() .statusCode(responseCode) .statusText(connection.getResponseMessage()) // TODO: Don't ignore abort? .headers(extractHeaders(connection)) .build()) .responseBody(responseBody) .build(); }
Example 2
Source File: V2DynamoDbAttributeValue.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private SdkHttpFullResponse fullResponse(TestItemUnmarshalling item) { AbortableInputStream abortableInputStream = AbortableInputStream.create(new ByteArrayInputStream(item.utf8())); return SdkHttpFullResponse.builder() .statusCode(200) .content(abortableInputStream) .build(); }
Example 3
Source File: MockHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private HttpExecuteResponse successResponse() { AbortableInputStream inputStream = AbortableInputStream.create(new ByteArrayInputStream(successResponseContent.getBytes())); return HttpExecuteResponse.builder() .response(SdkHttpResponse.builder() .statusCode(200) .build()) .responseBody(inputStream) .build(); }
Example 4
Source File: MockHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private HttpExecuteResponse errorResponse() { AbortableInputStream inputStream = AbortableInputStream.create(new ByteArrayInputStream(errorResponseContent.getBytes())); return HttpExecuteResponse.builder() .response(SdkHttpResponse.builder() .statusCode(500) .build()) .responseBody(inputStream) .build(); }
Example 5
Source File: BaseMockApiCall.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private AbortableInputStream generateContent(String protocol) { String content; switch (protocol) { case "xml": content = "<foo></foo>"; break; default: case "json": content = "{}"; } return AbortableInputStream.create(new ByteArrayInputStream(content.getBytes())); }
Example 6
Source File: SubscribeToShardUnmarshallingTest.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
public AbortableInputStream toInputStream() { return AbortableInputStream.create(new ByteArrayInputStream(baos.toByteArray())); }
Example 7
Source File: ApacheHttpClient.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
private AbortableInputStream toAbortableInputStream(HttpResponse apacheHttpResponse, HttpRequestBase apacheRequest) throws IOException { return AbortableInputStream.create(apacheHttpResponse.getEntity().getContent(), apacheRequest::abort); }
Example 8
Source File: Crc32Validation.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
private static AbortableInputStream crc32Validating(AbortableInputStream source, long expectedChecksum) { return AbortableInputStream.create(new Crc32ChecksumValidatingInputStream(source, expectedChecksum), source); }
Example 9
Source File: Crc32Validation.java From aws-sdk-java-v2 with Apache License 2.0 | 4 votes |
private static AbortableInputStream decompressing(AbortableInputStream source) { return AbortableInputStream.create(invokeSafely(() -> new GZIPInputStream(source)), source); }