Package org.jboss.netty.handler.codec.http

Examples of org.jboss.netty.handler.codec.http.HttpChunk


          //send back the /sources response
          HttpResponse sourcesResp = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
                                                             HttpResponseStatus.OK);
          sourcesResp.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
          sourcesResp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
          HttpChunk body =
              new DefaultHttpChunk(ChannelBuffers.wrappedBuffer(("[{\"id\":1,\"name\":\"" +
                                   SOURCE1_NAME + "\"}]").getBytes(Charset.defaultCharset())));
          NettyTestUtils.sendServerResponses(relay, clientAddr, sourcesResp, body);

          //make sure the client processes the response correctly
View Full Code Here


        //send back the /sources response
        HttpResponse sourcesResp = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
                                                           HttpResponseStatus.OK);
        sourcesResp.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
        sourcesResp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        HttpChunk body =
            new DefaultHttpChunk(ChannelBuffers.wrappedBuffer(("[{\"id\":1,\"name\":\"" +
                                 SOURCE1_NAME + "\"}]").getBytes(Charset.defaultCharset())));
        NettyTestUtils.sendServerResponses(relay, clientAddr, sourcesResp, body);

        //make sure the client processes the response correctly
View Full Code Here

        log.info("send back the /sources response");
        HttpResponse sourcesResp = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
                                                           HttpResponseStatus.OK);
        sourcesResp.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.KEEP_ALIVE);
        sourcesResp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        HttpChunk body =
            new DefaultHttpChunk(ChannelBuffers.wrappedBuffer(("[{\"id\":1,\"name\":\"" +
                                 SOURCE1_NAME + "\"}]").getBytes(Charset.defaultCharset())));
        NettyTestUtils.sendServerResponses(relay, clientAddr, sourcesResp, body);

        log.info("make sure the client processes the response correctly");
View Full Code Here

                            "Unsupported namespace. Only /" + STORE_OPS_NAMESPACE + "/ is supported.");
                }
                messageEvent.getChannel().write(response);
            }
        } else {
            HttpChunk chunk = (HttpChunk) messageEvent.getMessage();
            if(chunk.isLast()) {
                readingChunks = false;
            }
        }
    }
View Full Code Here

                    System.out.println("} END OF CONTENT");
                    this.client.responseReceived(response);
                }
            }
        } else {
            HttpChunk chunk = (HttpChunk) e.getMessage();
            if (chunk.isLast()) {
                readingChunks = false;
                System.out.println("} END OF CHUNKED CONTENT");
            } else {
//                System.out.print(chunk.getContent().toString(CharsetUtil.UTF_8));
                System.out.flush();
View Full Code Here

                    HttpHeaders.Names.CONTENT_LENGTH,
                    Integer.toString(m.getContent().readableBytes()));
            // Because HttpMessage is a mutable object, we can simply forward the write request.
            ctx.sendDownstream(e);
        } else if (msg instanceof HttpChunk) {
            HttpChunk c = (HttpChunk) msg;
            ChannelBuffer content = c.getContent();

            // Encode the chunk if necessary.
            if (encoder != null) {
                if (!c.isLast()) {
                    content = encode(content);
                    if (content.readable()) {
                        c.setContent(content);
                        ctx.sendDownstream(e);
                    }
                } else {
                    ChannelBuffer lastProduct = finishEncode();
View Full Code Here

                    }
                    // Reached to the end of response - close the request.
                    closeReal(succeededFuture(virtualChannel));
                }
            } else {
                HttpChunk chunk = (HttpChunk) e.getMessage();
                if (!chunk.isLast()) {
                    fireMessageReceived(HttpTunnelingClientSocketChannel.this, chunk.getContent());
                } else {
                    readingChunks = false;
                    // Reached to the end of response - close the request.
                    closeReal(succeededFuture(virtualChannel));
                }
View Full Code Here

 
  private void handleChunks(Object e)
  {
    if (e instanceof HttpChunk)
    {
      HttpChunk chunk = (HttpChunk) e;
      if (null != remoteHandler)
      {
        remoteHandler.handleChunk(this, chunk);
      }
    }
View Full Code Here

      }
      cacheCB.onResponse(response);
    }
    else
    {
      HttpChunk chunk = (HttpChunk) msg;
      callback.onBody(chunk);
      if (chunk.isLast())
      {
        readingChunks = false;
        if (keepalive)
        {
          inPool = client.putIdleConnection(remote, this);
View Full Code Here

      HttpResponse httpres = buildHttpResponse(res);
      localHandler.handleResponse(this, httpres);
      if (httpres.isChunked())
      {
        Buffer content = res.content;
        HttpChunk chunk = new DefaultHttpChunk(
                ChannelBuffers.wrappedBuffer(content.getRawBuffer(),
                        content.getReadIndex(), content.readableBytes()));
        localHandler.handleChunk(this, chunk);
      }
    }
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.HttpChunk

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.