Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer


  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
  {
    _response = (HttpResponse) e.getMessage();
    ChannelBuffer content = _response.getContent();
    _receivedBytes = new byte[content.readableBytes()];
    content.getBytes(0, _receivedBytes);
    _lock.lock();
    try
    {
      _hasResponse = true;
      _hasResponseCondition.signalAll();
View Full Code Here


                      " without " + HttpMessage.class.getSimpleName());
          }

          // Merge the received chunk into the content of the current message.
          HttpChunk chunk = (HttpChunk) msg;
          ChannelBuffer content = currentMessage.getContent();

          if (content.readableBytes() > maxContentLength - chunk.getContent().readableBytes()) {
              throw new TooLongFrameException(
                      "HTTP content length exceeded " + maxContentLength +
                      " bytes.");
          }

          content.writeBytes(chunk.getContent());
          if (chunk.isLast()) {
              this.currentMessage = null;
              currentMessage.setHeader(
                      HttpHeaders.Names.CONTENT_LENGTH,
                      String.valueOf(content.readableBytes()));
             
              if (chunk instanceof HttpChunkTrailer)
              {
                HttpChunkTrailer chunkTrailer = (HttpChunkTrailer)chunk;
                for(Entry<String, String> footer: chunkTrailer.getHeaders())
View Full Code Here

    //////// verify server gets the /stream request
    HttpRequest msgReq = captureRequest(objCapture);
    Assert.assertTrue(msgReq.getUri().startsWith("/stream"));

    ////// send back some partial response
    ChannelBuffer tmpBuf = NettyTestUtils.streamToChannelBuffer(buf, cp, 10000, null);
    _dummyServer.sendServerResponse(clientAddr, sourcesResp, 1000);
    _dummyServer.sendServerResponse(clientAddr, new DefaultHttpChunk(tmpBuf), 1000);

    //Trigger a read timeout
    TestUtil.sleep(DEFAULT_READ_TIMEOUT_MS + 100);
View Full Code Here

    //////// verify server gets the /stream request
    HttpRequest msgReq = captureRequest(objCapture);
    Assert.assertTrue(msgReq.getUri().startsWith("/stream"));

    ////// send back some partial response
    ChannelBuffer tmpBuf = NettyTestUtils.streamToChannelBuffer(buf, cp, 10000, null);
    _dummyServer.sendServerResponse(clientAddr, sourcesResp, 1000);
    _dummyServer.sendServerResponse(clientAddr, new DefaultHttpChunk(tmpBuf), 1000);

    serverChannel.close();
View Full Code Here

    // verify url construction for adding max event version
    String expectedVersion = "&" + DatabusHttpHeaders.MAX_EVENT_VERSION + "=" + MAX_EVENT_VERSION;
    Assert.assertTrue(msgReq.getUri().contains(expectedVersion));

    //send back some response
    ChannelBuffer tmpBuf = NettyTestUtils.streamToChannelBuffer(buf, cp, 10000, null);
    NettyTestUtils.sendServerResponses(_dummyServer, clientAddr, sourcesResp, new DefaultHttpChunk(tmpBuf));

    waitForCallback(callback,
                    TestResponseProcessors.TestConnectionStateMessage.State.STREAM_RESPONSE_SUCCESS,
                    log);
View Full Code Here

      syslogUtils.addFormats(prop);
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent mEvent) {
      ChannelBuffer buff = (ChannelBuffer) mEvent.getMessage();
      while (buff.readable()) {
        Event e = syslogUtils.extractEvent(buff);
        if (e == null) {
          logger.debug("Parsed partial event, event will be generated when " +
              "rest of the event is received.");
          continue;
View Full Code Here

      util = new SyslogUtils(
          SyslogUtils.DEFAULT_SIZE,
          SyslogUtils.chooseFieldsToKeep(keepFields),
          false);
    }
    ChannelBuffer buff = ChannelBuffers.buffer(200);

    buff.writeBytes(msg1.getBytes());
    Event e = util.extractEvent(buff);
    if(e == null){
      throw new NullPointerException("Event is null");
    }
    Map<String, String> headers2 = e.getHeaders();
View Full Code Here

   */
  @Test
  public void testExtractBadEvent1() {
    String badData1 = "<10F> bad bad data\n";
    SyslogUtils util = new SyslogUtils(false);
    ChannelBuffer buff = ChannelBuffers.buffer(100);
    buff.writeBytes(badData1.getBytes());
    Event e = util.extractEvent(buff);
    if(e == null){
      throw new NullPointerException("Event is null");
    }
    Map<String, String> headers = e.getHeaders();
View Full Code Here

  @Test
  public void testExtractBadEvent2() {
    String badData1 = "hi guys! <10> bad bad data\n";
    SyslogUtils util = new SyslogUtils(false);
    ChannelBuffer buff = ChannelBuffers.buffer(100);
    buff.writeBytes(badData1.getBytes());
    Event e = util.extractEvent(buff);
    if(e == null){
      throw new NullPointerException("Event is null");
    }
    Map<String, String> headers = e.getHeaders();
View Full Code Here

  @Test
  public void testExtractGoodEvent() {
    String priority = "<10>";
    String goodData1 = "Good good good data\n";
    SyslogUtils util = new SyslogUtils(false);
    ChannelBuffer buff = ChannelBuffers.buffer(100);
    buff.writeBytes((priority+goodData1).getBytes());
    Event e = util.extractEvent(buff);
    if(e == null){
      throw new NullPointerException("Event is null");
    }
    Map<String, String> headers = e.getHeaders();
View Full Code Here

TOP

Related Classes of org.jboss.netty.buffer.ChannelBuffer

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.