public String getContentType() { return response.getContentType(); }
String statusCode = statusCodeInt + " " + response.getStatusText(); String charset = ParallecGlobalConfig.httpResponseBodyCharsetUsesResponseContentType && response.getContentType()!=null ? AsyncHttpProviderUtils.parseCharset(response.getContentType()) : ParallecGlobalConfig.httpResponseBodyDefaultCharset; if(charset == null){
@Override public String getContentType() { return ningResponse.getContentType(); }
public String getContentType() { return response.getContentType(); }
public String getContentType() { return response.getContentType(); }
public String getContentType() { return response.getContentType(); }
@Override public boolean canRead(Response response) { return (response.getContentType() != null && (response.getContentType().startsWith(Http.JSON) || response .getContentType().endsWith("+json"))); }
@Override public boolean canRead(Response response) { return (response.getContentType() != null && (response.getContentType().startsWith(Http.XML) || response .getContentType().endsWith("+xml"))); }
private static String getResponseEncoding(Response response) { String encoding = response.getHeader("Content-Encoding"); if (encoding == null) { String contentType = response.getContentType(); if (contentType != null) { int charsetBegin = contentType.toLowerCase().indexOf(";charset="); if (charsetBegin >= 0) { encoding = contentType.substring(charsetBegin + ";charset=".length()); } } } return encoding; }
public <T> T resource(Class<T> type) { try { for (BodyReader br : this.bodyReaders) { if (br.canRead(ahcResponse)) { return br.readEntity(ahcResponse, type); } } } catch (IOException e) { throw new RuntimeException(e); } throw new RuntimeException("unsupported media type " + ahcResponse.getContentType()); }
public <T> T resource(Class<T> type, String charset) { try { for (BodyReader br : this.bodyReaders) { if (br.canRead(ahcResponse)) { return br.readEntity(ahcResponse, type, charset); } } } catch (IOException e) { throw new RuntimeException(e); } throw new RuntimeException("unsupported media type " + ahcResponse.getContentType()); }
public <T> T resource(TypeReference valueTypeRef) { try { for (BodyReader br : this.bodyReaders) { if (br.canRead(ahcResponse)) { return br.readEntity(ahcResponse, valueTypeRef); } } } catch (IOException e) { throw new RuntimeException(e); } throw new RuntimeException("unsupported media type " + ahcResponse.getContentType()); }
public <T> T resource(TypeReference valueTypeRef, String charset) { try { for (BodyReader br : this.bodyReaders) { if (br.canRead(ahcResponse)) { return br.readEntity(ahcResponse, valueTypeRef, charset); } } } catch (IOException e) { throw new RuntimeException(e); } throw new RuntimeException("unsupported media type " + ahcResponse.getContentType()); }
@Override public Response onCompleted(Response response) throws Exception { try { assertEquals(response.getStatusCode(), 200); assertEquals(response.getContentType(), TEXT_HTML_UTF_8); } finally { l.countDown(); } return response; } }).get();
@Override public Response onCompleted(Response response) throws Exception { try { assertEquals(response.getStatusCode(), 200); assertEquals(response.getContentType(), TEXT_HTML_UTF_8); } finally { l.countDown(); } return response; } }).get();
/** * Get the response body as a string. If the charset is not specified, this defaults to ISO-8859-1 for text * sub mime types, as per RFC-2616 sec 3.7.1, otherwise it defaults to UTF-8. */ public String getBody() { try { // RFC-2616#3.7.1 states that any text/* mime type should default to ISO-8859-1 charset if not // explicitly set, while Plays default encoding is UTF-8. So, use UTF-8 if charset is not explicitly // set and content type is not text/*, otherwise default to ISO-8859-1 String contentType = ahcResponse.getContentType(); if (contentType == null) { // As defined by RFC-2616#7.2.1 contentType = "application/octet-stream"; } String charset = AsyncHttpProviderUtils.parseCharset(contentType); if (charset != null) { return ahcResponse.getResponseBody(charset); } else if (contentType.startsWith("text/")) { return ahcResponse.getResponseBody(AsyncHttpProviderUtils.DEFAULT_CHARSET); } else { return ahcResponse.getResponseBody("utf-8"); } } catch (IOException e) { throw new RuntimeException(e); } }
String statusCode = statusCodeInt + " " + response.getStatusText(); String charset = ParallecGlobalConfig.httpResponseBodyCharsetUsesResponseContentType ? AsyncHttpProviderUtils.parseCharset(response.getContentType()) : ParallecGlobalConfig.httpResponseBodyDefaultCharset; reply(response.getResponseBody(charset), false, null, null, statusCode,
PreparedContentLocator contentLocator = new PreparedContentLocator( ris, response.getContentType() );