Top Description Fields Constructors Methods
org.eclipse.jetty.client

public Class OutputStreamRequestContent

extends OutputStreamContentSource
implements Content
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.client.Request.Content, org.eclipse.jetty.io.Content.Source
Imports
java.io.OutputStream, org.eclipse.jetty.io.content.OutputStreamContentSource

A Request.Content that provides content asynchronously through an OutputStream similar to AsyncRequestContent.

OutputStreamRequestContent can only be used in conjunction with Request#send(Response.CompleteListener) (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().

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public String
Inherited from org.eclipse.jetty.io.content.OutputStreamContentSource:
closedemandfailgetLengthgetOutputStreamread

Field Detail

contentTypeback to summary
private final String contentType

Constructor Detail

OutputStreamRequestContentback to summary
public OutputStreamRequestContent()
OutputStreamRequestContentback to summary
public OutputStreamRequestContent(String contentType)

Method Detail

getContentTypeback to summary
public String getContentType()

Overrides default org.eclipse.jetty.client.Request.Content.getContentType.

Returns:String

Doc from org.eclipse.jetty.client.Request.Content.getContentType.

the content type string such as "application/octet-stream" or "application/json;charset=UTF8", or null if the Content-Type header must not be set

Annotations
@Override