Codota Logo
com.ning.http.client.providers.netty.request.body
Code IndexAdd Codota to your IDE (free)

How to use com.ning.http.client.providers.netty.request.body

Best Java code snippets using com.ning.http.client.providers.netty.request.body (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: com.ning/async-http-client

@Override
public Body createBody() throws IOException {
  return new PushBody();
}
origin: com.ning/async-http-client

public void feed(final ByteBuffer buffer, final boolean isLast) throws IOException {
  queue.offer(new BodyPart(buffer, isLast));
  if (listener != null) {
    listener.onContentAdded();
  }
}
origin: com.ning/async-http-client

public long transferTo(WritableByteChannel target, long position) throws IOException {
  long count = this.count - position;
  if (count < 0 || position < 0) {
    throw new IllegalArgumentException("position out of range: " + position + " (expected: 0 - " + (this.count - 1) + ")");
  }
  if (count == 0) {
    return 0L;
  }
  long bw = file.transferTo(this.position + position, count, target);
  byteWritten += bw;
  if (byteWritten == raf.length()) {
    releaseExternalResources();
  }
  return bw;
}
origin: com.ning/async-http-client

nettyBody = new NettyByteArrayBody(request.getByteData());
nettyBody = new NettyCompositeByteArrayBody(request.getCompositeByteData());
nettyBody = new NettyByteBufferBody(StringUtils.charSequence2ByteBuffer(request.getStringData(), bodyCharset));
nettyBody = new NettyInputStreamBody(request.getStreamData());
  contentType = HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED;
nettyBody = new NettyByteBufferBody(urlEncodeFormParams(request.getFormParams(), bodyCharset), contentType);
nettyBody = new NettyMultipartBody(request.getParts(), request.getHeaders(), nettyConfig);
nettyBody = new NettyFileBody(request.getFile(), nettyConfig);
nettyBody = new NettyFileBody(fileBodyGenerator.getFile(), fileBodyGenerator.getRegionSeek(),
    fileBodyGenerator.getRegionLength(), nettyConfig);
nettyBody = new NettyInputStreamBody(InputStreamBodyGenerator.class.cast(request.getBodyGenerator()).getInputStream());
nettyBody = new NettyBodyBody(request.getBodyGenerator().createBody(), nettyConfig);
origin: io.gatling/async-http-client

private NettyBody body(Request request, HttpMethod method) throws IOException {
  NettyBody nettyBody = null;
  if (method != HttpMethod.CONNECT) {
    Charset bodyCharset = request.getBodyEncoding() == null ? DEFAULT_CHARSET : Charset.forName(request.getBodyEncoding());
    if (request.getByteData() != null)
      nettyBody = new NettyByteArrayBody(request.getByteData());
    else if (request.getStringData() != null)
      nettyBody = new NettyByteArrayBody(request.getStringData().getBytes(bodyCharset));
    else if (request.getStreamData() != null)
      nettyBody = new NettyInputStreamBody(request.getStreamData());
    else if (isNonEmpty(request.getFormParams())) {
      String contentType = null;
      if (!request.getHeaders().containsKey(HttpHeaders.Names.CONTENT_TYPE))
        contentType = HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED;
      nettyBody = new NettyByteArrayBody(computeBodyFromParams(request.getFormParams(), bodyCharset), contentType);
    } else if (isNonEmpty(request.getParts()))
      nettyBody = new NettyMultipartBody(request.getParts(), request.getHeaders(), nettyConfig);
    else if (request.getFile() != null)
      nettyBody = new NettyFileBody(request.getFile(), nettyConfig);
    else if (request.getBodyGenerator() instanceof FileBodyGenerator) {
      FileBodyGenerator fileBodyGenerator = (FileBodyGenerator) request.getBodyGenerator();
      nettyBody = new NettyFileBody(fileBodyGenerator.getFile(), fileBodyGenerator.getRegionSeek(),
          fileBodyGenerator.getRegionLength(), nettyConfig);
    } else if (request.getBodyGenerator() instanceof InputStreamBodyGenerator)
      nettyBody = new NettyInputStreamBody(InputStreamBodyGenerator.class.cast(request.getBodyGenerator()).getInputStream());
    else if (request.getBodyGenerator() != null)
      nettyBody = new NettyBodyBody(request.getBodyGenerator().createBody(), nettyConfig);
  }
  return nettyBody;
}
origin: com.ning/async-http-client

msg = new BodyFileRegion((RandomAccessBody) body);
msg = new BodyChunkedInput(body);
  feedableBodyGenerator.writeChunkBoundaries();
  feedableBodyGenerator.setListener(new FeedListener() {
    @Override
    public void onContentAdded() {
origin: com.ning/async-http-client

NettyRequest nettyRequest;
if (body instanceof NettyDirectBody) {
  ChannelBuffer buffer = NettyDirectBody.class.cast(body).channelBuffer();
  httpRequest = new DefaultHttpRequest(httpVersion, method, requestUri);
  if (body.getContentLength() < 0)
    headers.set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
  else
    headers.set(HttpHeaders.Names.CONTENT_LENGTH, body.getContentLength());
  if (body.getContentType() != null)
    headers.set(HttpHeaders.Names.CONTENT_TYPE, body.getContentType());
origin: io.gatling/async-http-client

NettyRequest nettyRequest;
if (body instanceof NettyByteArrayBody) {
  byte[] bytes = NettyByteArrayBody.class.cast(body).getBytes();
  httpRequest = new DefaultHttpRequest(httpVersion, method, requestUri);
  if (body.getContentLength() > 0)
    httpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, body.getContentLength());
  else
    httpRequest.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
  if (body.getContentType() != null)
    httpRequest.headers().set(HttpHeaders.Names.CONTENT_TYPE, body.getContentType());
origin: io.gatling/async-http-client

  @Override
  public void write(final Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException {

    Object msg;
    if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.getPipeline()) && !nettyConfig.isDisableZeroCopy()) {
      msg = new BodyFileRegion((RandomAccessBody) body);

    } else {
      msg = new BodyChunkedInput(body);
      
      BodyGenerator bg = future.getRequest().getBodyGenerator();
      if (bg instanceof FeedableBodyGenerator) {
        FeedableBodyGenerator.class.cast(bg).setListener(new FeedListener() {
          @Override
          public void onContentAdded() {
            channel.getPipeline().get(ChunkedWriteHandler.class).resumeTransfer();
          }
        });
      }
    }
    
    channel.write(msg).addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) {
      public void operationComplete(ChannelFuture cf) {
        closeSilently(body);
        super.operationComplete(cf);
      }
    });
  }
}
origin: com.ning/async-http-client

  @Override
  public void write(Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException {
    final RandomAccessFile raf = new RandomAccessFile(file, "r");

    try {
      ChannelFuture writeFuture;
      if (ChannelManager.isSslHandlerConfigured(channel.getPipeline()) || nettyConfig.isDisableZeroCopy()) {
        writeFuture = channel.write(new ChunkedFile(raf, offset, raf.length(), nettyConfig.getChunkedFileChunkSize()));
      } else {
        final FileRegion region = new OptimizedFileRegion(raf, offset, raf.length());
        writeFuture = channel.write(region);
      }
      writeFuture.addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) {
        public void operationComplete(ChannelFuture cf) {
          closeSilently(raf);
          super.operationComplete(cf);
        }
      });
    } catch (IOException ex) {
      closeSilently(raf);
      throw ex;
    }
  }
}
origin: com.ning/async-http-client

channel.write(new BodyChunkedInput(body)).addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) {
  public void operationComplete(ChannelFuture cf) {
    closeSilently(body);
origin: com.ning/async-http-client

public <T> void writeRequest(NettyResponseFuture<T> future, Channel channel) {
  NettyRequest nettyRequest = future.getNettyRequest();
  HttpRequest httpRequest = nettyRequest.getHttpRequest();
  AsyncHandler<T> handler = future.getAsyncHandler();
  // if the channel is dead because it was pooled and the remote
  // server decided to close it,
  // we just let it go and the channelInactive do its work
  if (!Channels.isChannelValid(channel))
    return;
  try {
    if (handler instanceof TransferCompletionHandler)
      configureTransferAdapter(handler, httpRequest);
    if (!future.isHeadersAlreadyWrittenOnContinue()) {
      if (future.getAsyncHandler() instanceof AsyncHandlerExtensions)
        AsyncHandlerExtensions.class.cast(future.getAsyncHandler()).onSendRequest(nettyRequest);
      channel.write(httpRequest).addListener(new ProgressListener(config, future.getAsyncHandler(), future, true));
    }
    if (nettyRequest.getBody() != null && !future.isDontWriteBodyBecauseExpectContinue() && httpRequest.getMethod() != HttpMethod.CONNECT)
      nettyRequest.getBody().write(channel, future, config);
    // don't bother scheduling timeouts if channel became invalid
    if (Channels.isChannelValid(channel))
      scheduleTimeouts(future);
  } catch (Throwable t) {
    LOGGER.error("Can't write request", t);
    Channels.silentlyCloseChannel(channel);
  }
}
origin: io.gatling/async-http-client

  writeRequest(f.getChannel(), poolKey);
abortChannelPreemption(poolKey);
Throwable cause = f.getCause();
origin: com.ning/async-http-client

  state = writeChunkBoundaries ? PushBodyState.CLOSING : PushBodyState.FINISHED;
return read(buffer);
origin: io.gatling/async-http-client

private void writeRequest(Channel channel, String poolKey) {
  LOGGER.debug("Request using non cached Channel '{}':\n{}\n", channel, future.getNettyRequest().getHttpRequest());
  if (future.isDone()) {
    abortChannelPreemption(poolKey);
    return;
  }
  channelManager.registerOpenChannel(channel);
  future.attachChannel(channel, false);
  requestSender.writeRequest(future, channel);
}
origin: io.gatling/async-http-client

channelFuture.addListener(new NettyConnectListener<T>(config, future, this, channelManager, channelPreempted, poolKey));
origin: io.gatling/async-http-client

public long transferTo(WritableByteChannel target, long position) throws IOException {
  long count = this.count - position;
  if (count < 0 || position < 0) {
    throw new IllegalArgumentException("position out of range: " + position + " (expected: 0 - " + (this.count - 1) + ")");
  }
  if (count == 0) {
    return 0L;
  }
  long bw = file.transferTo(this.position + position, count, target);
  byteWritten += bw;
  if (byteWritten == raf.length()) {
    releaseExternalResources();
  }
  return bw;
}
origin: io.gatling/async-http-client

  @Override
  public void write(Channel channel, NettyResponseFuture<?> future, AsyncHttpClientConfig config) throws IOException {
    final RandomAccessFile raf = new RandomAccessFile(file, "r");

    try {
      ChannelFuture writeFuture;
      if (ChannelManager.isSslHandlerConfigured(channel.getPipeline()) || nettyConfig.isDisableZeroCopy()) {
        writeFuture = channel.write(new ChunkedFile(raf, offset, raf.length(), nettyConfig.getChunkedFileChunkSize()));
      } else {
        final FileRegion region = new OptimizedFileRegion(raf, offset, raf.length());
        writeFuture = channel.write(region);
      }
      writeFuture.addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) {
        public void operationComplete(ChannelFuture cf) {
          closeSilently(raf);
          super.operationComplete(cf);
        }
      });
    } catch (IOException ex) {
      closeSilently(raf);
      throw ex;
    }
  }
}
origin: io.gatling/async-http-client

channel.write(new BodyChunkedInput(body)).addListener(new ProgressListener(config, future.getAsyncHandler(), future, false) {
  public void operationComplete(ChannelFuture cf) {
    closeSilently(body);
origin: io.gatling/async-http-client

nettyRequest.getBody().write(channel, future, config);
com.ning.http.client.providers.netty.request.body

Most used classes

  • BodyChunkedInput
    Adapts a Body to Netty's ChunkedInput.
  • BodyFileRegion
    Adapts a RandomAccessBody to Netty's FileRegion.
  • NettyBody
  • NettyBodyBody
  • NettyByteArrayBody
  • NettyInputStreamBody,
  • NettyMultipartBody,
  • OptimizedFileRegion,
  • FeedableBodyGenerator$BodyPart,
  • FeedableBodyGenerator$FeedListener,
  • FeedableBodyGenerator$PushBody,
  • FeedableBodyGenerator,
  • NettyByteBufferBody,
  • NettyCompositeByteArrayBody,
  • NettyConnectListener,
  • NettyDirectBody
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now