@Override public String getContentType() { return entity.getContentType(); }
bae.setContentType(entity.getContentType());
@Override public String getContentType() { return original.getContentType(); }
@Override public String getContentType() { return wrappedEntity.getContentType(); }
@Override public String getContentType() { return wrappedEntity.getContentType(); }
@Override public String getContentType() { return wrappedEntity.getContentType(); }
@Override public String getContentType() { return entity.getContentType(); }
@Override public String getContentType() { return wrappedEntity.getContentType(); }
/** * Extracts {@code Content-Type} value from {@link HttpEntity} exactly as * specified by the {@code Content-Type} header of the entity. Returns {@code null} * if not specified. * * @param entity HTTP entity * @return content type * {@code Content-Type} value. * @throws UnsupportedCharsetException Thrown when the named charset is not available in * this instance of the Java virtual machine */ public static ContentType getContentType(final HttpEntity entity) throws UnsupportedCharsetException { if (entity == null) { return null; } final String contentType = entity.getContentType(); if (contentType != null) { return ContentType.parse(contentType); } return null; }
/** * Extracts {@code Content-Type} value from {@link HttpEntity}. Returns {@code null} * if not specified or incorrect (could not be parsed).. * * @param entity HTTP entity * @return content type * * @since 4.4 * */ public static ContentType getContentTypeLenient(final HttpEntity entity) { if (entity == null) { return null; } final String contentType = entity.getContentType(); if (contentType != null) { return ContentType.parseLenient(contentType); } return null; }
/** * Extracts {@code Content-Type} value from {@link HttpEntity}. Returns {@code null} * if not specified or incorrect (could not be parsed).. * * @param entity HTTP entity * @return content type * * @since 4.4 * */ public static ContentType getContentTypeLenient(final HttpEntity entity) { if (entity == null) { return null; } final String contentType = entity.getContentType(); if (contentType != null) { return ContentType.parseLenient(contentType); } return null; }
/** * Extracts {@code Content-Type} value from {@link HttpEntity} exactly as * specified by the {@code Content-Type} header of the entity. Returns {@code null} * if not specified. * * @param entity HTTP entity * @return content type * {@code Content-Type} value. * @throws UnsupportedCharsetException Thrown when the named charset is not available in * this instance of the Java virtual machine */ public static ContentType getContentType(final HttpEntity entity) throws UnsupportedCharsetException { if (entity == null) { return null; } final String contentType = entity.getContentType(); if (contentType != null) { return ContentType.parse(contentType); } return null; }
final String contentType = entity == null ? null : entity.getContentType();
final String contentType = entity == null ? null : entity.getContentType();
if (requestContentType != null) { final HttpEntity entity = request.getEntity(); final String contentType = entity.getContentType(); final String expectedContentType = (String) requestExpectations.get(CONTENT_TYPE); if (! contentType.equals(expectedContentType)) {
if (requestContentType != null) { final HttpEntity entity = request.getEntity(); final String contentType = entity.getContentType(); final String expectedContentType = (String) requestExpectations.get(CONTENT_TYPE); if (! contentType.equals(expectedContentType)) {
@Test public void testCreateEntityLengthDelimited() throws Exception { final InputStream inStream = Mockito.mock(InputStream.class); final ClassicHttpResponse message = new BasicClassicHttpResponse(200, "OK"); message.addHeader("Content-Length", "10"); message.addHeader("Content-Type", "stuff"); message.addHeader("Content-Encoding", "chunked"); final HttpEntity entity = conn.createIncomingEntity(message, conn.inBuffer, inStream, 10); Assert.assertNotNull(entity); Assert.assertFalse(entity.isChunked()); Assert.assertEquals(10, entity.getContentLength()); Assert.assertEquals("stuff", entity.getContentType()); Assert.assertEquals("chunked", entity.getContentEncoding()); final InputStream content = entity.getContent(); Assert.assertNotNull(content); Assert.assertTrue((content instanceof ContentLengthInputStream)); }