コード例 #1
0
 private BufferedJerseyRequestHttpEntity(ClientRequest clientRequest) {
   final ByteArrayOutputStream stream = new ByteArrayOutputStream(BUFFER_INITIAL_SIZE);
   clientRequest.setStreamProvider(contentLength -> stream);
   try {
     clientRequest.writeEntity();
   } catch (IOException e) {
     throw new ProcessingException(LocalizationMessages.ERROR_BUFFERING_ENTITY(), e);
   }
   buffer = stream.toByteArray();
   setChunked(false);
 }
コード例 #2
0
ファイル: JettyConnector.java プロジェクト: kingsfleet/jersey
  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();
          }
        });

    try {
      clientRequest.writeEntity();
    } catch (final IOException e) {
      throw new ProcessingException("Failed to write request entity.", e);
    }
    return streamContentProvider;
  }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public void writeTo(final OutputStream outputStream) throws IOException {
   clientRequest.setStreamProvider(contentLength -> outputStream);
   clientRequest.writeEntity();
 }