public boolean hasResponseHeaders() { return response.hasResponseHeaders(); }
/** * Converts async-http-client response to okhttp response. * * @param asyncHttpClientResponse async-http-client response * @return okhttp response. * @throws NullPointerException in case of null arguments */ private Response toOkhttpResponse(org.asynchttpclient.Response asyncHttpClientResponse) { // status code val rspBuilder = new Response.Builder() .request(request()) .protocol(Protocol.HTTP_1_1) .code(asyncHttpClientResponse.getStatusCode()) .message(asyncHttpClientResponse.getStatusText()); // headers if (asyncHttpClientResponse.hasResponseHeaders()) { asyncHttpClientResponse.getHeaders().forEach(e -> rspBuilder.header(e.getKey(), e.getValue())); } // body if (asyncHttpClientResponse.hasResponseBody()) { val contentType = asyncHttpClientResponse.getContentType() == null ? null : MediaType.parse(asyncHttpClientResponse.getContentType()); val okHttpBody = ResponseBody.create(contentType, asyncHttpClientResponse.getResponseBodyAsBytes()); rspBuilder.body(okHttpBody); } else { rspBuilder.body(EMPTY_BODY); } return rspBuilder.build(); }
public boolean hasResponseHeaders() { return response.hasResponseHeaders(); }