Package ch.mimo.netty.handler.codec.icap

Examples of ch.mimo.netty.handler.codec.icap.IcapRequest


  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    Object message = e.getMessage();
    IcapResponse response = null;
    if(message instanceof IcapRequest) {
      IcapRequest request = (IcapRequest)message;
      System.out.println("");
      System.out.println("---------------------------- receiving " + request.getMethod() + " ----------------------------");
      System.out.print(message.toString());
      if(request.getMethod().equals(IcapMethod.OPTIONS)) {
        response = new DefaultIcapResponse(IcapVersion.ICAP_1_0,IcapResponseStatus.OK);
        response.addHeader("Options-TTL","3600");
        response.addHeader("Service-ID","Test Icap Server");
        response.addHeader("Allow","204");
        response.addHeader("Preview","1024");
        response.addHeader("Methods","REQMOD, RESPMOD");
       
      } else if(request.isPreviewMessage()) {
        response = new DefaultIcapResponse(IcapVersion.ICAP_1_0,IcapResponseStatus.NO_CONTENT);
      } else {
        response = new DefaultIcapResponse(IcapVersion.ICAP_1_0,IcapResponseStatus.OK);
        response.addHeader(IcapHeaders.Names.ISTAG,"Echo-Server-1.0");
        if(request.getMethod().equals(IcapMethod.REQMOD)) {
          response.setHttpRequest(request.getHttpRequest());
        }
        response.setHttpResponse(request.getHttpResponse());
      }
      System.out.println("");
      System.out.println("---------------------------- sending " + response.getStatus() + " ----------------------------");
      System.out.print(response.toString());
      ctx.getChannel().write(response);
View Full Code Here


public abstract class SocketTests extends AbstractSocketTest {
 
  private class SendOPTIONSRequestServerHandler extends AbstractHandler {
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      IcapRequest request = (IcapRequest)event.getMessage();
      DataMockery.assertCreateOPTIONSRequest(request);
      channel.write(DataMockery.createOPTIONSIcapResponse());
      return true;
    }
View Full Code Here

  }
 
  private class SendRESPMODWithGetRequestNoBodyServerHandler extends AbstractHandler {
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      IcapRequest request = (IcapRequest)event.getMessage();
      DataMockery.assertCreateRESPMODWithGetRequestNoBody(request);
      channel.write(DataMockery.createRESPMODWithGetRequestNoBodyIcapResponse());
      return true;
    }
View Full Code Here

    boolean thirdChunk = false;
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)event.getMessage();
        DataMockery.assertCreateREQMODWithTwoChunkBody(request);
        requestMessage = true;
      } else if(msg instanceof IcapChunk) {
        IcapChunk chunk = (IcapChunk)msg;
        if(!firstChunk) {
View Full Code Here

    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)event.getMessage();
        DataMockery.assertCreateREQMODWithTwoChunkBody(request);
        ChannelBuffer contentBuffer = request.getHttpRequest().getContent();
        String body = contentBuffer.toString(Charset.forName("ASCII"));
        StringBuilder builder = new StringBuilder();
        builder.append("This is data that was returned by an origin server.");
        builder.append("And this the second chunk which contains more information.");
        assertEquals("The body content was wrong",builder.toString(),body);
View Full Code Here

    boolean secondChunk = false;
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)event.getMessage();
        DataMockery.assertCreateREQMODWithPreview(request);
        requestMessage = true;
      } else if(msg instanceof IcapChunk) {
        IcapChunk chunk = (IcapChunk)msg;
        if(!firstChunk) {
View Full Code Here

    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)event.getMessage();
        DataMockery.assertCreateREQMODWithPreview(request);
        ChannelBuffer requestBodyBuffer = request.getHttpRequest().getContent();
        String body = requestBodyBuffer.toString(Charset.forName("ASCII"));
        StringBuilder builder = new StringBuilder();
        builder.append("This is data that was returned by an origin server.");
        assertEquals("The body content was wrong",builder.toString(),body);
        channel.write(DataMockery.createREQMODWithPreviewAnnouncement204ResponseIcapMessage());
View Full Code Here

    boolean fourthChunk = false;
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)event.getMessage();
        DataMockery.assertCreateREQMODWithPreview(request);
        requestMessage = true;
      } else if(msg instanceof IcapChunk) {
        IcapChunk chunk = (IcapChunk)msg;
        if(!firstChunk) {
View Full Code Here

   
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)msg;
        requestReceived = true;
        dataReceived = request.getHttpRequest().getContent().readableBytes() > 0;
        channel.write(DataMockery.createREQMODWithDataIcapResponse());
      }
      return requestReceived & dataReceived;
    }
View Full Code Here

   
    @Override
    public boolean doMessageReceived(ChannelHandlerContext context, MessageEvent event, Channel channel) throws Exception {
      Object msg = event.getMessage();
      if(msg instanceof IcapRequest) {
        IcapRequest request = (IcapRequest)msg;
        DataMockery.assertCreateREQMODWithPostRequestAndDataIcapRequest(request);
        IcapResponse response = DataMockery.createREQMODWithPostRequestIcapResponse();
        if(counter >= 100) {
          response.addHeader("TEST","END");
        }
View Full Code Here

TOP

Related Classes of ch.mimo.netty.handler.codec.icap.IcapRequest

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.