A Request. that provides content asynchronously through an OutputStream
similar to AsyncRequestContent.
OutputStreamRequestContent can only be used in conjunction with
Request#send(Response. (and not with its blocking counterpart
Request#send()) because it provides content asynchronously.
Content must be provided by writing to the output stream
that must be closed when all content has been provided.
Example usage:
HttpClient httpClient = ...;
// Use try-with-resources to autoclose the output stream.
OutputStreamRequestContent content = new OutputStreamRequestContent();
try (OutputStream output = content.getOutputStream())
{
httpClient.newRequest("localhost", 8080)
.body(content)
.send(new Response.CompleteListener()
{
@Override
public void onComplete(Result result)
{
// Your logic here
}
});
// At a later time...
output.write("some content".getBytes());
// Even later...
output.write("more content".getBytes());
} // Implicit call to output.close().
| Modifier and Type | Field and Description |
|---|---|
| private final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String |
| contentType | back to summary |
|---|---|
| private final String contentType | |
| OutputStreamRequestContent | back to summary |
|---|---|
| public OutputStreamRequestContent() | |
| OutputStreamRequestContent | back to summary |
|---|---|
| public OutputStreamRequestContent(String contentType) | |
| getContentType | back to summary |
|---|---|
| public String getContentType() Overrides default org.
| |