bae.setContentType(entity.getContentType());
public HttpResponse returnResponse() throws IOException { assertNotConsumed(); try { final HttpEntity entity = this.response.getEntity(); if (entity != null) { final ByteArrayEntity byteArrayEntity = new ByteArrayEntity( EntityUtils.toByteArray(entity)); final ContentType contentType = EntityUtils.getContentTypeOrDefault(entity); byteArrayEntity.setContentType(contentType.toString()); this.response.setEntity(byteArrayEntity); } return this.response; } finally { this.consumed = true; } }
/** * @since 4.2 */ public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) < 0) || ((off + len) > b.length)) { throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length); } this.b = b; this.off = off; this.len = len; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) < 0) || ((off + len) > b.length)) { throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length); } this.b = b; this.off = off; this.len = len; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public ByteArrayEntity(final byte[] b, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); this.b = b; this.off = 0; this.len = this.b.length; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public ByteArrayEntity(final byte[] b, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); this.b = b; this.off = 0; this.len = this.b.length; if (contentType != null) { setContentType(contentType.toString()); } }
public HttpResponse returnResponse() throws IOException { assertNotConsumed(); try { final HttpEntity entity = this.response.getEntity(); if (entity != null) { final ByteArrayEntity byteArrayEntity = new ByteArrayEntity( EntityUtils.toByteArray(entity)); final ContentType contentType = EntityUtils.getContentTypeOrDefault(entity); byteArrayEntity.setContentType(contentType.toString()); this.response.setEntity(byteArrayEntity); } return this.response; } finally { this.consumed = true; } }