use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.
the class TestCodeFirstJaxrs method testDeleteAfterFinished.
private void testDeleteAfterFinished() throws Exception {
ReadStreamPart part = downloadInf.testDeleteAfterFinished("hello", "hello content");
TestMgr.check(part.saveAsString().get(), "hello content");
File systemTempFile = new File(System.getProperty("java.io.tmpdir"));
File file = new File(systemTempFile, "hello");
TestMgr.check(file.exists(), false);
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.
the class TestDownload method templateExchange.
private ReadStreamPart templateExchange(String methodPath, String type) {
HttpHeaders headers = new HttpHeaders();
headers.add("accept", type);
HttpEntity<?> entity = new HttpEntity<>(headers);
ResponseEntity<ReadStreamPart> response = consumers.getSCBRestTemplate().exchange("/" + methodPath + "?content={content}", HttpMethod.GET, entity, ReadStreamPart.class, content);
return response.getBody();
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.
the class RestClientSender method processResponse.
protected Future<Buffer> processResponse(HttpClientResponse httpClientResponse) {
transportContext.setHttpClientResponse(httpClientResponse);
if (HttpStatus.isSuccess(httpClientResponse.statusCode()) && transportContext.isDownloadFile()) {
ReadStreamPart streamPart = new ReadStreamPart(transportContext.getVertxContext(), httpClientResponse);
future.complete(createResponse(httpClientResponse, streamPart));
}
return httpClientResponse.body();
}
use of org.apache.servicecomb.foundation.vertx.http.ReadStreamPart in project incubator-servicecomb-java-chassis by apache.
the class RestClientInvocation method handleResponse.
protected void handleResponse(HttpClientResponse httpClientResponse) {
this.clientResponse = httpClientResponse;
if (HttpStatus.isSuccess(clientResponse.statusCode()) && restOperationMeta.isDownloadFile()) {
ReadStreamPart part = new ReadStreamPart(httpClientWithContext.context(), httpClientResponse);
invocation.getHandlerContext().put(RestConst.READ_STREAM_PART, part);
processResponseBody(null);
return;
}
httpClientResponse.exceptionHandler(e -> {
invocation.getTraceIdLogger().error(LOGGER, "Failed to receive response, local:{}, remote:{}, message={}.", getLocalAddress(), httpClientResponse.netSocket().remoteAddress(), ExceptionUtils.getExceptionMessageWithoutTrace(e));
fail(e);
});
clientResponse.bodyHandler(this::processResponseBody);
}
Aggregations