本文整理匯總了Java中org.apache.http.entity.ContentType.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentType.parse方法的具體用法?Java ContentType.parse怎麽用?Java ContentType.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.entity.ContentType
的用法示例。
在下文中一共展示了ContentType.parse方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCoverArtSuffix
import org.apache.http.entity.ContentType; //導入方法依賴的package包/類
private String getCoverArtSuffix(HttpResponse response) {
String result = null;
Header contentTypeHeader = response.getEntity().getContentType();
if (contentTypeHeader != null && contentTypeHeader.getValue() != null) {
ContentType contentType = ContentType.parse(contentTypeHeader.getValue());
String mimeType = contentType.getMimeType();
result = StringUtil.getSuffix(mimeType);
}
return result == null ? "jpeg" : result;
}
示例2: getInputStreamEntity
import org.apache.http.entity.ContentType; //導入方法依賴的package包/類
private InputStreamEntity getInputStreamEntity(HttpServletRequest request) throws IOException
{
int contentLength = request.getContentLength();
ContentType contentType = null;
if (request.getContentType() != null) {
contentType = ContentType.parse(request.getContentType());
}
return new InputStreamEntity(request.getInputStream(), contentLength, contentType);
}
示例3: getContentType
import org.apache.http.entity.ContentType; //導入方法依賴的package包/類
private ContentType getContentType(Request request) {
ContentType contentType = ContentType.DEFAULT_TEXT;
for (Map.Entry<String, Collection<String>> entry : request.headers().entrySet())
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
Collection<String> values = entry.getValue();
if (values != null && !values.isEmpty()) {
contentType = ContentType.parse(values.iterator().next());
break;
}
}
return contentType;
}
示例4: createContentType
import org.apache.http.entity.ContentType; //導入方法依賴的package包/類
public static ContentType createContentType(String mediaType) {
return ContentType.parse(mediaType);
}