@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 code of the response */ @Override public int getStatus() { return ahcResponse.getStatusCode(); }
/** * Get the HTTP status text of the response */ @Override public String getStatusText() { return ahcResponse.getStatusText(); }
/** * 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; }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
/** * 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); } } }
/** * 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; }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
/** * 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); } } }
/** * Get only one cookie, using the cookie name. */ @Override public Optional<WSCookie> getCookie(String name) { for (Cookie ahcCookie : ahcResponse.getCookies()) { // safe -- cookie.getName() will never return null if (ahcCookie.name().equals(name)) { return Optional.of(asCookie(ahcCookie)); } } return Optional.empty(); }
@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 code of the response */ @Override public int getStatus() { return ahcResponse.getStatusCode(); }
/** * Get the HTTP status text of the response */ @Override public String getStatusText() { return ahcResponse.getStatusText(); }
/** * Get only one cookie, using the cookie name. */ @Override public Optional<WSCookie> getCookie(String name) { for (Cookie ahcCookie : ahcResponse.getCookies()) { // safe -- cookie.getName() will never return null if (ahcCookie.name().equals(name)) { return Optional.of(asCookie(ahcCookie)); } } return Optional.empty(); }