本文整理了Java中com.ning.http.client.Response.getResponseBodyAsBytes
方法的一些代码示例,展示了Response.getResponseBodyAsBytes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getResponseBodyAsBytes
方法的具体详情如下:
包路径:com.ning.http.client.Response
类名称:Response
方法名:getResponseBodyAsBytes
[英]Return the entire response body as a byte[].
[中]以字节[]的形式返回整个响应体。
代码示例来源:origin: com.ning/async-http-client
@Override
public byte[] getResponseBodyAsBytes() throws IOException {
return response.getResponseBodyAsBytes();
}
代码示例来源:origin: HubSpot/Singularity
private BaragonResponse readResponse(Response response) {
try {
return objectMapper.readValue(response.getResponseBodyAsBytes(), BaragonResponse.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client
@Override
public byte[] getResponseBodyAsBytes() throws IOException {
return response.getResponseBodyAsBytes();
}
代码示例来源:origin: outbrain/ob1k
@Override
public byte[] getResponseBodyAsBytes() throws IOException {
return ningResponse.getResponseBodyAsBytes();
}
代码示例来源:origin: javaee/grizzly-ahc
@Override
public byte[] getResponseBodyAsBytes() throws IOException {
return response.getResponseBodyAsBytes();
}
代码示例来源:origin: io.gatling/async-http-client
@Override
public byte[] getResponseBodyAsBytes() throws IOException {
return response.getResponseBodyAsBytes();
}
代码示例来源:origin: play/play-java
/**
* Get the response body as a byte array
* @return The byte array
*/
public byte[] asByteArray() {
try {
return ahcResponse.getResponseBodyAsBytes();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.hubspot/SingularityService
private BaragonResponse readResponse(Response response) {
try {
return objectMapper.readValue(response.getResponseBodyAsBytes(), BaragonResponse.class);
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
代码示例来源:origin: io.sphere.sdk.jvm/java-client
private byte[] getResponseBodyAsBytes(final Response response) {
try {
return response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http-ning-1_8
private byte[] getResponseBodyAsBytes(final Response response) {
try {
return response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/sdk-http-ahc-1_9
private byte[] getResponseBodyAsBytes(final Response response) {
try {
return response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private byte[] getResponseBodyAsBytes(final Response response) {
try {
return response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
private byte[] getResponseBodyAsBytes(final Response response) {
try {
final boolean gzipEncoded =
Optional.ofNullable(response.getHeader(HttpHeaders.CONTENT_ENCODING))
.map(v -> v.equalsIgnoreCase("gzip"))
.orElse(false);
return gzipEncoded ? unzip(response) : response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: io.sphere.sdk.jvm/sdk-http-ahc-1_8
private byte[] getResponseBodyAsBytes(final Response response) {
try {
final boolean gzipEncoded =
Optional.ofNullable(response.getHeader(HttpHeaders.CONTENT_ENCODING))
.map(v -> v.equalsIgnoreCase("gzip"))
.orElse(false);
return gzipEncoded ? unzip(response) : response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: com.commercetools.sdk.jvm.core/sdk-http-ahc-1_8
private byte[] getResponseBodyAsBytes(final Response response) {
try {
final boolean gzipEncoded =
Optional.ofNullable(response.getHeader(HttpHeaders.CONTENT_ENCODING))
.map(v -> v.equalsIgnoreCase("gzip"))
.orElse(false);
return gzipEncoded ? unzip(response) : response.getResponseBodyAsBytes();
} catch (IOException e) {
throw new HttpException(e);
}
}
代码示例来源:origin: stackoverflow.com
public class RestClient {
public static void main(String[] args)
throws ExecutionException, InterruptedException, IOException, ClassNotFoundException {
AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
Response r = asyncHttpClient.prepareGet("http://127.0.0.1:5701/hazelcast/rest/maps/default/key1")
.execute().get();
ObjectInputStream objectInputStream = new ObjectInputStream(
new ByteArrayInputStream(r.getResponseBodyAsBytes()));
final Person o = (Person) objectInputStream.readObject();
System.out.println(o.toString());
}
}
代码示例来源:origin: org.elasticsoftware.elasticactors-systems/elasticactors-systems-http
@Override
public Integer onCompleted(Response response) throws Exception {
// get the headers
Map<String,List<String>> headers = response.getHeaders();
replyAddress.tell(new HttpResponse(response.getStatusCode(),
headers,
response.getResponseBodyAsBytes()),serviceAddress);
return response.getStatusCode();
}
代码示例来源:origin: org.elasticsoftware.elasticactors/elasticactors-http
@Override
public Integer onCompleted(Response response) throws Exception {
// get the headers
Map<String,List<String>> headers = response.getHeaders();
replyAddress.tell(new HttpResponse(response.getStatusCode(),
headers,
response.getResponseBodyAsBytes()),serviceAddress);
return response.getStatusCode();
}
代码示例来源:origin: javaee/grizzly-ahc
@Test(groups = { "default_provider", "async" })
public void mirrorByteTest() throws Throwable {
try (AsyncHttpClient client = getAsyncHttpClient(null)) {
Response r = client.preparePost(getTargetUrl()).setBody("MIRROR").execute().get();
assertEquals(r.getStatusCode(), 200);
assertEquals(new String(r.getResponseBodyAsBytes(), "UTF-8"), "MIRROR");
}
}
代码示例来源:origin: javaee/grizzly-ahc
@Test(groups = { "default_provider", "async" })
public void bodyAsByteTest() throws Throwable {
try (AsyncHttpClient client = getAsyncHttpClient(new Builder().build())) {
Response r = client.prepareGet(getTargetUrl()).execute().get();
assertEquals(r.getStatusCode(), 200);
assertEquals(r.getResponseBodyAsBytes(), new byte[] {});
}
}
内容来源于网络,如有侵权,请联系作者删除!