use of org.eclipse.jetty.client.util.OutputStreamContentProvider in project jetty.project by eclipse.
the class Usage method testRequestOutputStream.
@Test
public void testRequestOutputStream() throws Exception {
HttpClient client = new HttpClient();
client.start();
OutputStreamContentProvider content = new OutputStreamContentProvider();
try (OutputStream output = content.getOutputStream()) {
client.newRequest("localhost", 8080).content(content).send(new Response.CompleteListener() {
@Override
public void onComplete(Result result) {
Assert.assertEquals(200, result.getResponse().getStatus());
}
});
output.write(new byte[1024]);
output.write(new byte[512]);
output.write(new byte[256]);
output.write(new byte[128]);
}
}
use of org.eclipse.jetty.client.util.OutputStreamContentProvider in project jersey by jersey.
the class JettyConnector method getStreamProvider.
private ContentProvider getStreamProvider(final ClientRequest clientRequest) {
final Object entity = clientRequest.getEntity();
if (entity == null) {
return null;
}
final OutputStreamContentProvider streamContentProvider = new OutputStreamContentProvider();
clientRequest.setStreamProvider(new OutboundMessageContext.StreamProvider() {
@Override
public OutputStream getOutputStream(final int contentLength) throws IOException {
return streamContentProvider.getOutputStream();
}
});
return streamContentProvider;
}
Aggregations