/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data, Files.TemporaryFileCreator tempFileCreator) { return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data, Files.TemporaryFileCreator tempFileCreator) { return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Set a Binary Data to this request. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @param tempFileCreator the temporary file creator for binary data. * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data, Files.TemporaryFileCreator tempFileCreator) { return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Set a Binary Data to this request using a singleton temporary file creator. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data) { Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Set a Binary Data to this request using a singleton temporary file creator. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data) { Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Set a Binary Data to this request using a singleton temporary file creator. * The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>. * * @param data the Binary Data * @return the modified builder */ public RequestBuilder bodyRaw(byte[] data) { Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator(); return bodyRaw(ByteString.fromArray(data), tempFileCreator); }
/** * Generates a simple result with byte-array content. * * @param status the HTTP status for this result e.g. 200 (OK), 404 (NOT_FOUND) * @param content the result's body content, as a byte array * @return the result */ public static Result status(int status, byte[] content) { if (content == null) { throw new NullPointerException("Null content"); } return new Result(status, new HttpEntity.Strict(ByteString.fromArray(content), Optional.empty())); }
/** * Generates a simple result with byte-array content. * * @param status the HTTP status for this result e.g. 200 (OK), 404 (NOT_FOUND) * @param content the result's body content, as a byte array * @return the result */ public static Result status(int status, byte[] content) { if (content == null) { throw new NullPointerException("Null content"); } return new Result(status, new HttpEntity.Strict(ByteString.fromArray(content), Optional.empty())); }
/** * Generates a simple result with byte-array content. * * @param status the HTTP status for this result e.g. 200 (OK), 404 (NOT_FOUND) * @param content the result's body content, as a byte array * @return the result */ public static Result status(int status, byte[] content) { if (content == null) { throw new NullPointerException("Null content"); } return new Result(status, new HttpEntity.Strict(ByteString.fromArray(content), Optional.empty())); }
return (ByteString) body; } else if (body instanceof byte[]) { return ByteString.fromArray((byte[]) body); } else if (body instanceof String) { return ByteString.fromString((String) body);
return (ByteString) body; } else if (body instanceof byte[]) { return ByteString.fromArray((byte[]) body); } else if (body instanceof String) { return ByteString.fromString((String) body);
return (ByteString) body; } else if (body instanceof byte[]) { return ByteString.fromArray((byte[]) body); } else if (body instanceof String) { return ByteString.fromString((String) body);
/** * Creates a {@link InMemoryBodyWritable} from a byte array. * * @param array the byte array to pass in. * @param contentType to pass in. * @return a {@link InMemoryBodyWritable} instance. */ default BodyWritable<ByteString> body(byte[] array, String contentType) { return new InMemoryBodyWritable(ByteString.fromArray(array), contentType); }
/** * Creates a {@link InMemoryBodyWritable} from a byte array. * * @param array the byte array to pass in. * @param contentType to pass in. * @return a {@link InMemoryBodyWritable} instance. */ default BodyWritable<ByteString> body(byte[] array, String contentType) { return new InMemoryBodyWritable(ByteString.fromArray(array), contentType); }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
@Override public ByteString getBodyAsBytes() { return ByteString.fromArray(this.ahcResponse.getResponseBodyAsBytes()); }
public void onComplete() { if (completion.isDone()) { return; } try { flushBuffer(); } catch (final IOException e) { // no-op } final String contentType = headers.remove("Content-Type"); headers.remove("Content-Length"); completion.complete(new Result(status, headers, new HttpEntity.Strict(ByteString.fromArray(output.toByteArray()), ofNullable(contentType)))); }
@Override public Source<ByteString, ?> getBodyAsSource() { return Source.fromPublisher(publisher).map(bodyPart -> ByteString.fromArray(bodyPart.getBodyPartBytes())); }
@Override public Source<ByteString, ?> getBodyAsSource() { return Source.fromPublisher(publisher).map(bodyPart -> ByteString.fromArray(bodyPart.getBodyPartBytes())); }