- java.lang.Object
-
- com.github.mizosoft.methanol.MoreBodyPublishers
-
public class MoreBodyPublishers extends java.lang.ObjectStatic factories for additionalHttpRequest.BodyPublisherimplementations.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MimeBodyPublisherofMediaType(java.net.http.HttpRequest.BodyPublisher bodyPublisher, MediaType mediaType)Adapts the givenBodyPublisherinto aMimeBodyPublisherwith the given media type.static java.net.http.HttpRequest.BodyPublisherofObject(java.lang.Object object, @Nullable MediaType mediaType)Returns aBodyPublisherthat encodes the given object into a request body using an installedencoder.static java.net.http.HttpRequest.BodyPublisherofOutputStream(ThrowingConsumer<? super java.io.OutputStream> writerTask, java.util.concurrent.Executor executor)Returns aBodyPublisherthat reads what's written to theOutputStreamreceived by the given task.static java.net.http.HttpRequest.BodyPublisherofWritableByteChannel(ThrowingConsumer<? super java.nio.channels.WritableByteChannel> writerTask, java.util.concurrent.Executor executor)Returns aBodyPublisherthat reads what's written to theWritableByteChannelreceived by the given task.
-
-
-
Method Detail
-
ofOutputStream
public static java.net.http.HttpRequest.BodyPublisher ofOutputStream(ThrowingConsumer<? super java.io.OutputStream> writerTask, java.util.concurrent.Executor executor)
Returns aBodyPublisherthat reads what's written to theOutputStreamreceived by the given task. When the returned publisher receives a subscriber (i.e. when the HTTP client starts sending the request body), the given task is executed by the given executor to write the body's content. The latter is asynchronously channeled to the HTTP client.
-
ofWritableByteChannel
public static java.net.http.HttpRequest.BodyPublisher ofWritableByteChannel(ThrowingConsumer<? super java.nio.channels.WritableByteChannel> writerTask, java.util.concurrent.Executor executor)
Returns aBodyPublisherthat reads what's written to theWritableByteChannelreceived by the given task. When the returned publisher receives a subscriber (i.e. when the HTTP client starts sending the request body), the given task is executed by the given executor to write the body's content. The latter is asynchronously channeled to the HTTP client.
-
ofMediaType
public static MimeBodyPublisher ofMediaType(java.net.http.HttpRequest.BodyPublisher bodyPublisher, MediaType mediaType)
Adapts the givenBodyPublisherinto aMimeBodyPublisherwith the given media type.
-
ofObject
public static java.net.http.HttpRequest.BodyPublisher ofObject(java.lang.Object object, @Nullable MediaType mediaType)Returns aBodyPublisherthat encodes the given object into a request body using an installedencoder.- Throws:
java.lang.UnsupportedOperationException- if noBodyAdapter.Encoderthat supports the given object's runtime type or the given media type is installed
-
-