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

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


                                    HttpResponse sourcesResp) throws JsonGenerationException,
      JsonMappingException,
      IOException
  {
    HttpRequest msgReq;
    HttpChunk body;
    objCapture.clear();
    conn.requestRegister("1", msg);

    //verify server gets the /register request
    msgReq = captureRequest(objCapture);
View Full Code Here


    //send back some 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\":\"test.source1\"}]".getBytes(Charset.defaultCharset())));
    NettyTestUtils.sendServerResponses(_dummyServer, clientAddr, sourcesResp, body);

    waitForCallback(callback,
                    TestResponseProcessors.TestConnectionStateMessage.State.SOURCES_SUCCESS,
View Full Code Here

        // store response, as this channel handler is created per pipeline
        Object msg = messageEvent.getMessage();

        // it may be a chunked message
        if (msg instanceof HttpChunk) {
            HttpChunk chunk = (HttpChunk) msg;
            if (LOG.isTraceEnabled()) {
                LOG.trace("HttpChunk received: {} isLast: {}", chunk, chunk.isLast());
            }

            if (msg instanceof HttpChunkTrailer) {
                // chunk trailer only has headers
                HttpChunkTrailer trailer = (HttpChunkTrailer) msg;
                for (Map.Entry<String, String> entry : trailer.trailingHeaders()) {
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Adding trailing header {}={}", entry.getKey(), entry.getValue());
                    }
                    response.headers().add(entry.getKey(), entry.getValue());
                }
            } else {
                // append chunked content
                buffer.writeBytes(chunk.getContent());
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Wrote {} bytes to chunk buffer", buffer.writerIndex());
                }
            }
            if (chunk.isLast()) {
                // the content is a copy of the buffer with the actual data we wrote to it
                int end = buffer.writerIndex();
                ChannelBuffer copy = buffer.copy(0, end);
                // the copy must not be readable when the content was chunked, so set the index to the end
                copy.setIndex(end, end);
View Full Code Here

        // store response, as this channel handler is created per pipeline
        Object msg = messageEvent.getMessage();

        // it may be a chunked message
        if (msg instanceof HttpChunk) {
            HttpChunk chunk = (HttpChunk) msg;
            if (LOG.isTraceEnabled()) {
                LOG.trace("HttpChunk received: {} isLast: {}", chunk, chunk.isLast());
            }

            if (msg instanceof HttpChunkTrailer) {
                // chunk trailer only has headers
                HttpChunkTrailer trailer = (HttpChunkTrailer) msg;
                for (Map.Entry<String, String> entry : trailer.getHeaders()) {
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Adding trailing header {}={}", entry.getKey(), entry.getValue());
                    }
                    response.addHeader(entry.getKey(), entry.getValue());
                }
            } else {
                // append chunked content
                buffer.writeBytes(chunk.getContent());
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Wrote {} bytes to chunk buffer", buffer.writerIndex());
                }
            }
            if (chunk.isLast()) {
                // the content is a copy of the buffer with the actual data we wrote to it
                int end = buffer.writerIndex();
                ChannelBuffer copy = buffer.copy(0, end);
                // the copy must not be readable when the content was chunked, so set the index to the end
                copy.setIndex(end, end);
View Full Code Here

                }

                registerRequest(requestValidator, ctx, messageEvent);
            }
        } else {
            HttpChunk chunk = (HttpChunk) messageEvent.getMessage();
            if(chunk.isLast()) {
                readingChunks = false;
            }
        }
    }
View Full Code Here

                    readingChunks = true;
                } else {
                    copyContentToTmpFile(response.getContent());
                }
            } else {
                HttpChunk chunk = (HttpChunk) e.getMessage();
                if (chunk.isLast()) {
                    readingChunks = false;
                    fos.close();
                } else {
                    copyContentToTmpFile(chunk.getContent());
                }
            }

        }
View Full Code Here

        HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        resp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        sendServerResponse(clientAddr, resp, 1000);

        HttpChunk chunk1 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk1".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk1, 1000);

        HttpChunk chunk2 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk2".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk2, 1000);

        sendServerResponse(clientAddr, new DefaultHttpChunkTrailer(), 1000);

        final List<String> callbacks = respProcessor.getCallbacks();
View Full Code Here

        HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        resp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        sendServerResponse(clientAddr, resp, 1000);

        HttpChunk chunk1 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk1".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk1, 1000);

        HttpChunk chunk2 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk2".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk2, 1000);

        sendServerResponse(clientAddr, new DefaultHttpChunkTrailer(), 1000);
        TestUtil.sleep(200);
        sendServerClose(clientAddr, -1);
View Full Code Here

          }
        }, "make sure we have all tracking populated for client connection", 1000, log);

        sendServerResponse(clientAddr, resp, 1000);

        HttpChunk chunk1 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk1".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk1, 1000);

        TestUtil.sleep(200);

        sendServerClose(clientAddr, -1);
View Full Code Here

        HttpResponse resp = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        resp.setHeader(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
        sendServerResponse(clientAddr, resp, 1000);

        HttpChunk chunk1 = new DefaultHttpChunk(ChannelBuffers.wrappedBuffer("chunk1".getBytes(Charset.defaultCharset())));
        sendServerResponse(clientAddr, chunk1, 1000);
        final List<String> callbacks = respProcessor.getCallbacks();

        TestUtil.assertWithBackoff(new ConditionCheck()
        {
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.