Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make request chunking work with Netty 4.0.6 #1693

Closed
slandelle opened this issue Aug 4, 2013 · 5 comments
Closed

Can't make request chunking work with Netty 4.0.6 #1693

slandelle opened this issue Aug 4, 2013 · 5 comments
Assignees
Milestone

Comments

@slandelle
Copy link
Contributor

Hi,

I'm desperately trying to make ChunkedStream work on the client side, ie for chuking a request body.

Here's what my code look like (a similar code works fine with Netty 3).

plainBootstrap.handler(new ChannelInitializer<Channel>() {

  protected void initChannel(Channel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast("httpHandler", new HttpClientCodec());
    pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
    pipeline.addLast("httpProcessor", new WriteStreamHandler(latch, status, responseBodySize));
  }
});

ChannelFuture f = plainBootstrap.connect(new InetSocketAddress("127.0.0.1", port1));

f.addListener(new ChannelFutureListener() {
  public void operationComplete(ChannelFuture future) throws Exception {
    DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, getTargetUrl());
    request.headers().add(HttpHeaders.Names.ACCEPT, "*/*");
    request.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
    request.headers().add(HttpHeaders.Names.HOST, "*127.0.0.1:" + port1);
    request.headers().add(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);

    future.channel().write(request);
    future.channel().write(new ChunkedStream(new ByteArrayInputStream("hello".getBytes())));
    future.channel().writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
  }
});

I've created a test case here: https://github.com/slandelle/netty-request-chunking

Regards,

Stéphane

@normanmaurer
Copy link
Member

@slandelle fixed by 60b8893 . Please retest.

@slandelle
Copy link
Contributor Author

Will do, thanks!

2013/8/7 Norman Maurer notifications@github.com

@slandelle https://github.com/slandelle fixed by 60b889360b8893. Please retest.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1693#issuecomment-22235098
.

@normanmaurer
Copy link
Member

I just notice you use FullHttpRequest… what you want to use is HttpRequest.

Am 07.08.2013 um 10:31 schrieb Stephane Landelle notifications@github.com:

Will do, thanks!

2013/8/7 Norman Maurer notifications@github.com

@slandelle https://github.com/slandelle fixed by 60b889360b8893. Please retest.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1693#issuecomment-22235098
.


Reply to this email directly or view it on GitHub.

@slandelle
Copy link
Contributor Author

I've updated my sample (https://github.com/slandelle/netty-request-chunking) but it's still not working. Am I doing something wrong?

@normanmaurer
Copy link
Member

@slandelle your test has a bug... pull in and re-run: https://github.com/slandelle/netty-request-chunking/pull/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants