public static void toHttpResponse(byte[] byteArray, HttpResponse response, String contentType) throws IOException { NByteArrayEntity body = new NByteArrayEntity(byteArray); body.setContentType(contentType); response.setEntity(body); response.setStatusCode(HttpStatus.SC_OK); }
public static void toHttpResponse(byte[] byteArray, HttpResponse response, String contentType) throws IOException { NByteArrayEntity body = new NByteArrayEntity(byteArray); body.setContentType(contentType); response.setEntity(body); response.setStatusCode(HttpStatus.SC_OK); }
private static NByteArrayEntity byteBody(HttpReq config) { NByteArrayEntity entity = new NByteArrayEntity(config.body()); if (config.contentType() != null) { entity.setContentType(config.contentType()); } return entity; }
/** * @since 4.2 */ public NByteArrayEntity(final byte[] b, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); this.b = b; this.off = 0; this.len = b.length; this.buf = ByteBuffer.wrap(b); this.content = b; this.buffer = this.buf; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public NByteArrayEntity(final byte[] b, final ContentType contentType) { super(); Args.notNull(b, "Source byte array"); this.b = b; this.off = 0; this.len = b.length; this.buf = ByteBuffer.wrap(b); this.content = b; this.buffer = this.buf; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public NByteArrayEntity(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; this.buf = ByteBuffer.wrap(b, off, len); this.content = b; this.buffer = this.buf; if (contentType != null) { setContentType(contentType.toString()); } }
/** * @since 4.2 */ public NByteArrayEntity(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; this.buf = ByteBuffer.wrap(b, off, len); this.content = b; this.buffer = this.buf; if (contentType != null) { setContentType(contentType.toString()); } }
public static void toHttpResponse(byte[] byteArray, HttpResponse response, String contentType) throws IOException { NByteArrayEntity body = new NByteArrayEntity(byteArray); body.setContentType(contentType); response.setEntity(body); response.setStatusCode(HttpStatus.SC_OK); }