com.ning.http.client.Response.getContentType()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中com.ning.http.client.Response.getContentType方法的一些代码示例,展示了Response.getContentType的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getContentType方法的具体详情如下:
包路径:com.ning.http.client.Response
类名称:Response
方法名:getContentType

Response.getContentType介绍

[英]Return the content-type header value.
[中]返回内容类型标题值。

代码示例

代码示例来源:origin: com.ning/async-http-client

public String getContentType() {
  return response.getContentType();
}

代码示例来源:origin: eBay/parallec

String statusCode = statusCodeInt + " " + response.getStatusText();
String charset = ParallecGlobalConfig.httpResponseBodyCharsetUsesResponseContentType &&
    response.getContentType()!=null ? 
    AsyncHttpProviderUtils.parseCharset(response.getContentType())
    : ParallecGlobalConfig.httpResponseBodyDefaultCharset;
if(charset == null){

代码示例来源:origin: outbrain/ob1k

@Override
public String getContentType() {
 return ningResponse.getContentType();
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client

public String getContentType() {
  return response.getContentType();
}

代码示例来源:origin: io.gatling/async-http-client

public String getContentType() {
  return response.getContentType();
}

代码示例来源:origin: javaee/grizzly-ahc

public String getContentType() {
  return response.getContentType();
}

代码示例来源:origin: resthub/resthub-spring-stack

@Override
public boolean canRead(Response response) {
  return (response.getContentType() != null && (response.getContentType().startsWith(Http.JSON) || response
      .getContentType().endsWith("+json")));
}

代码示例来源:origin: resthub/resthub-spring-stack

@Override
public boolean canRead(Response response) {
  return (response.getContentType() != null && (response.getContentType().startsWith(Http.XML) || response
      .getContentType().endsWith("+xml")));
}

代码示例来源:origin: net.adamcin.granite/granite-client-packman

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;
}

代码示例来源:origin: resthub/resthub-spring-stack

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());
}

代码示例来源:origin: resthub/resthub-spring-stack

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());
}

代码示例来源:origin: resthub/resthub-spring-stack

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());
}

代码示例来源:origin: resthub/resthub-spring-stack

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());
}

代码示例来源:origin: javaee/grizzly-ahc

@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();

代码示例来源:origin: javaee/grizzly-ahc

@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();

代码示例来源:origin: play/play-java

/**
 * 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);
  }
}

代码示例来源:origin: io.parallec/parallec-core

String statusCode = statusCodeInt + " " + response.getStatusText();
String charset = ParallecGlobalConfig.httpResponseBodyCharsetUsesResponseContentType ? 
    AsyncHttpProviderUtils.parseCharset(response.getContentType())
    : ParallecGlobalConfig.httpResponseBodyDefaultCharset;
reply(response.getResponseBody(charset), false, null, null, statusCode,

代码示例来源:origin: org.sonatype.nexus/nexus-proxy

PreparedContentLocator contentLocator = new PreparedContentLocator( ris, response.getContentType() );

相关文章