@Override public String getContentType() { String contentType = ahcResponse.getContentType(); if (contentType == null) { // As defined by RFC-2616#7.2.1 contentType = "application/octet-stream"; } return contentType; }
/** * Get the HTTP status text of the response */ @Override public String getStatusText() { return ahcResponse.getStatusText(); }
/** * Get the HTTP status code of the response */ @Override public int getStatus() { return ahcResponse.getStatusCode(); }
static Realm auth(String username, String password, WSAuthScheme scheme) { Realm.AuthScheme authScheme = Realm.AuthScheme.valueOf(scheme.name()); Boolean usePreemptiveAuth = scheme != WSAuthScheme.DIGEST; return (new Realm.Builder(username, password)) .setScheme(authScheme) .setUsePreemptiveAuth(usePreemptiveAuth) .build(); } }
CompletionStage<StandaloneWSResponse> executeStream(Request request, ExecutionContext ec) { final Promise<StandaloneWSResponse> scalaPromise = scala.concurrent.Promise$.MODULE$.apply(); asyncHttpClient.executeRequest(request, new DefaultStreamedAsyncHandler<>(state -> new StreamedResponse(this, state.statusCode(), state.statusText(), state.uriOption().get(), state.responseHeaders(), state.publisher(), asyncHttpClient.getConfig().isUseLaxCookieEncoder()), scalaPromise)); return FutureConverters.toJava(scalaPromise.future()); }
/** * Return the request {@link URI}. Note that if the request got redirected, the value of the * {@link URI} will be the last valid redirect url. * * @return the request {@link URI}. */ public URI getUri() { try { return ahcResponse.getUri().toJavaNetURI(); } catch (URISyntaxException e) { throw new RuntimeException(e); } } }
@Override public void close() throws IOException { asyncHttpClient.close(); }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
@Override public Source<ByteString, ?> getBodyAsSource() { return Source.fromPublisher(publisher).map(bodyPart -> ByteString.fromArray(bodyPart.getBodyPartBytes())); }
/** * Get all the cookies. */ @Override public List<WSCookie> getCookies() { return ahcResponse.getCookies().stream().map(this::asCookie).collect(toList()); }
/** * Get all the HTTP headers of the response as a case-insensitive map */ @Override public Map<String, List<String>> getHeaders() { final Map<String, List<String>> headerMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); final HttpHeaders headers = ahcResponse.getHeaders(); for (String name : headers.names()) { final List<String> values = headers.getAll(name); headerMap.put(name, values); } return headerMap; }
static Realm auth(String username, String password, WSAuthScheme scheme) { Realm.AuthScheme authScheme = Realm.AuthScheme.valueOf(scheme.name()); Boolean usePreemptiveAuth = scheme != WSAuthScheme.DIGEST; return (new Realm.Builder(username, password)) .setScheme(authScheme) .setUsePreemptiveAuth(usePreemptiveAuth) .build(); } }
CompletionStage<StandaloneWSResponse> executeStream(Request request, ExecutionContext ec) { final Promise<StandaloneWSResponse> scalaPromise = scala.concurrent.Promise$.MODULE$.apply(); asyncHttpClient.executeRequest(request, new DefaultStreamedAsyncHandler<>(state -> new StreamedResponse(this, state.statusCode(), state.statusText(), state.uriOption().get(), state.responseHeaders(), state.publisher(), asyncHttpClient.getConfig().isUseLaxCookieEncoder()), scalaPromise)); return FutureConverters.toJava(scalaPromise.future()); }
/** * Return the request {@link URI}. Note that if the request got redirected, the value of the * {@link URI} will be the last valid redirect url. * * @return the request {@link URI}. */ public URI getUri() { try { return ahcResponse.getUri().toJavaNetURI(); } catch (URISyntaxException e) { throw new RuntimeException(e); } } }
@Override public String getContentType() { String contentType = ahcResponse.getContentType(); if (contentType == null) { // As defined by RFC-2616#7.2.1 contentType = "application/octet-stream"; } return contentType; }
/** * Get the HTTP status text of the response */ @Override public String getStatusText() { return ahcResponse.getStatusText(); }
/** * Get the HTTP status code of the response */ @Override public int getStatus() { return ahcResponse.getStatusCode(); }
@Override public void close() throws IOException { asyncHttpClient.close(); }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
@Override public Source<ByteString, ?> getBodyAsSource() { return Source.fromPublisher(publisher).map(bodyPart -> ByteString.fromArray(bodyPart.getBodyPartBytes())); }