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
  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;
  }
 /** {@inheritDoc} */
 @Override
 public void writeTo(final OutputStream outputStream) throws IOException {
   clientRequest.setStreamProvider(contentLength -> outputStream);
   clientRequest.writeEntity();
 }