Package org.xlightweb.AbstractHttpConnection

Examples of org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler


       
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("[" + httpConnection.getId() + "] Error occured by calling on disconnect " + pe.toString());
        }
       
        IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
        if (messageHeaderHandler != null) {
            messageHeaderHandler.onHeaderException(pe, rawData);
        }
    }
View Full Code Here


   
    if (requestHeader != null) {
      httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
      httpConnection.incCountMessageReceived();

      IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
      if (messageHeaderHandler == null) {
        throw new IOException("no message handler set");
      }
     
     
      HttpRequest request = null;
     
      switch (getBodyType(requestHeader)) {
       
        case BODY_TYPE_EMTPY:
          request = new HttpRequest(requestHeader);
          IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          messageHandler.onMessageReceived();
         
          rawData = HttpUtils.compact(rawData);
          reset();
         
          // next request? (-> pipelining)
          if (rawData != null) {
            return onData(httpConnection, rawData);
          }               
         
          break;
         
        case FULL_MESSAGE:
          AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(httpConnection, requestHeader.getCharacterEncoding(), requestHeader.getContentLength());
          setBodyDataSource(dataSource);
         
          request = new HttpRequest(requestHeader, dataSource);
          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          setMessageHandler(messageHandler);
         
          setState(RECEIVING_BODY);
         
          request.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
          return parserBody(httpConnection, rawData);
         
        default// BODY_TYPE_CHUNKED
          dataSource = new FullMessageChunkedBodyDataSource(httpConnection, requestHeader);
            setBodyDataSource(dataSource);
               
            request = new HttpRequest(requestHeader, dataSource);

          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          setMessageHandler(messageHandler);

          setState(RECEIVING_BODY);

          request.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
View Full Code Here

            setState(RECEIVING_BODY);

      httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
      httpConnection.incCountMessageReceived();
       
      IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
      if (messageHeaderHandler == null) {
        throw new IOException("no message handler set");
      }
     
      try {     
                int bodyType = getBodyType(httpConnection, responseHeader, (IHttpRequestHeader) messageHeaderHandler.getAssociatedHeader());
        switch (bodyType) {
         
          case BODY_TYPE_EMTPY:
            HttpResponse response = new HttpResponse(responseHeader);
           
            IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            messageHandler.onHeaderProcessed();
           
            httpConnection.onMessageCompleteReceived(responseHeader);
           
            setMessageHandler(messageHandler);
            reset();
           
           
            // next response? (-> pipelining)
            if (rawData != null) {
              return onData(httpConnection, rawData);
            }   
            break;

           
          case FULL_MESSAGE:
              AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(responseHeader, httpConnection);
              setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);

                      messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
                      try {
                        setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
                      } finally {
              messageHandler.onHeaderProcessed();
            }             
           
            break;
           
          case BODY_TYPE_SIMPLE:
              dataSource = new SimpleMessageBodyDataSource(responseHeader, httpConnection);
                        setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);
           
            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
                    setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
            } finally {
              messageHandler.onHeaderProcessed();
            }
            break;
           
          case BODY_TYPE_MULTIPART_BYTERANGE:             
              dataSource = new MultipartByteRangeMessageBodyDataSource(httpConnection, responseHeader);
              setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);

            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
              setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
            } finally {
              messageHandler.onHeaderProcessed();
            }
            break;
           
           
          default// BODY_TYPE_CHUNKED
            dataSource = new FullMessageChunkedBodyDataSource(httpConnection, responseHeader);
              setBodyDataSource(dataSource);

            response = new HttpResponse(responseHeader, dataSource);
           
            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
              setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
View Full Code Here

        setState(RECEIVING_BODY);
       
        HttpResponse response = new HttpResponse(responseHeader, dataSource, true);

       
        IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler(); // get it before disconnecting dataSource!
        if (messageHeaderHandler == null) {
            throw new IOException("no message handler set");
        }
       
        dataSource.parse(rawData);
        dataSource.onDisconnect();  
       
        IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
        setMessageHandler(messageHandler);
        messageHandler.onHeaderProcessed();
  }
View Full Code Here

                    onDisconnectInHeader(httpConnection, rawData);
                } catch (IOException ioe) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("[" + httpConnection.getId() + "] Error occured by calling on disconnect while receiving header " + ioe.toString());
                    }
                    IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
                    if (messageHeaderHandler != null) {
                        messageHeaderHandler.onHeaderException(ioe, rawData);
                    }
                }

            // ... no
            } else {
View Full Code Here

     
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("[" + httpConnection.getId() + "] error occured " + pe.toString());
        }       
       
        IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
        if (messageHeaderHandler != null) {
            messageHeaderHandler.onHeaderException(pe, rawData);
        }
    }
View Full Code Here

        requestHeader.setBodyDefaultEncoding(httpConnection.getBodyDefaultEncoding());
       
      httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
      httpConnection.incCountMessageReceived();

      IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
      if (messageHeaderHandler == null) {
        throw new IOException("no message handler set");
      }
     
     
      HttpRequest request = null;
     
      switch (getBodyType(requestHeader)) {
       
        case BODY_TYPE_EMTPY:
          request = new HttpRequest(requestHeader);
          IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          messageHandler.onHeaderProcessed();
         
          messageHandler.onMessageReceived();
          httpConnection.onMessageCompleteReceived(requestHeader);
         
          rawData = HttpUtils.compact(rawData);
          reset();
         
          // next request? (-> pipelining)
          if (rawData != null) {
            return onData(httpConnection, rawData);
          }               
         
          break;
         
        case FULL_MESSAGE:
          AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(requestHeader, httpConnection);
          setBodyDataSource(dataSource);
         
          request = new HttpRequest(requestHeader, dataSource);
          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          try {
            setMessageHandler(messageHandler);
           
            setState(RECEIVING_BODY);
           
            request.getNonBlockingBody().setBodyDataReceiveTimeoutMillisSilence(httpConnection.getBodyDataReceiveTimeoutMillis());
            rawData = parserBody(httpConnection, rawData);
          } finally {
            messageHandler.onHeaderProcessed();
          }
         
          return rawData;
         
        default// BODY_TYPE_CHUNKED
          dataSource = new FullMessageChunkedBodyDataSource(httpConnection, requestHeader);
            setBodyDataSource(dataSource);
               
            request = new HttpRequest(requestHeader, dataSource);

          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          try {
            setMessageHandler(messageHandler);
 
            setState(RECEIVING_BODY);
 
View Full Code Here

        requestHeader.setBodyDefaultEncoding(httpConnection.getBodyDefaultEncoding());
       
      httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
      httpConnection.incCountMessageReceived();

      IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
      if (messageHeaderHandler == null) {
        throw new IOException("no message handler set");
      }
     
     
      HttpRequest request = null;
     
      switch (getBodyType(requestHeader)) {
       
        case BODY_TYPE_EMTPY:
          request = new HttpRequest(requestHeader);
          IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          messageHandler.onHeaderProcessed();
         
          messageHandler.onMessageReceived();
          httpConnection.onMessageCompleteReceived(requestHeader);
         
          rawData = HttpUtils.compact(rawData);
          reset();
         
          // next request? (-> pipelining)
          if (rawData != null) {
            return onData(httpConnection, rawData);
          }               
         
          break;
         
        case BODY_TYPE_FULL_MESSAGE:
          AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(requestHeader, requestHeader.getContentLength(), httpConnection);
          setBodyDataSource(dataSource);
         
          request = new HttpRequest(requestHeader, dataSource);
          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          try {
            setMessageHandler(messageHandler);
           
            setState(RECEIVING_BODY);
           
            request.getNonBlockingBody().setBodyDataReceiveTimeoutMillisSilence(httpConnection.getBodyDataReceiveTimeoutMillis());
            rawData = parserBody(httpConnection, rawData);
          } finally {
            messageHandler.onHeaderProcessed();
          }
         
          return rawData;
         
         
                case BODY_TYPE_WEBSOCKET:
                    dataSource = new FullMessageBodyDataSource(requestHeader, 8, httpConnection);
                    setBodyDataSource(dataSource);
                   
                    request = new HttpRequest(requestHeader, dataSource);
                    request.removeHeader("Content-Length");
                    messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
                    try {
                        setMessageHandler(messageHandler);
                       
                        setState(RECEIVING_BODY);
                       
                        request.getNonBlockingBody().setBodyDataReceiveTimeoutMillisSilence(httpConnection.getBodyDataReceiveTimeoutMillis());
                        rawData = parserBody(httpConnection, rawData);
                    } finally {
                        messageHandler.onHeaderProcessed();
                    }
                   
                    return rawData;
         
         
        default// BODY_TYPE_CHUNKED
          dataSource = new FullMessageChunkedBodyDataSource(httpConnection, requestHeader);
            setBodyDataSource(dataSource);
               
            request = new HttpRequest(requestHeader, dataSource);

          messageHandler = messageHeaderHandler.onMessageHeaderReceived(request);
          try {
            setMessageHandler(messageHandler);
 
            setState(RECEIVING_BODY);
 
View Full Code Here

            setState(RECEIVING_BODY);

      httpConnection.setLastTimeHeaderReceivedMillis(System.currentTimeMillis());
      httpConnection.incCountMessageReceived();
       
      IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler();
      if (messageHeaderHandler == null) {
        throw new IOException("no message handler set");
      }
     
      try {     
                int bodyType = getBodyType(httpConnection, responseHeader, (IHttpRequestHeader) messageHeaderHandler.getAssociatedHeader());
        switch (bodyType) {
         
          case BODY_TYPE_EMTPY:
            HttpResponse response = new HttpResponse(responseHeader);
           
            IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            messageHandler.onHeaderProcessed();
           
            httpConnection.onMessageCompleteReceived(responseHeader);
           
            setMessageHandler(messageHandler);
            reset();
           
           
            // next response? (-> pipelining)
            if (rawData != null) {
              return onData(httpConnection, rawData);
            }   
            break;

           
          case BODY_TYPE_FULL_MESSAGE:
              AbstractNetworkBodyDataSource dataSource = new FullMessageBodyDataSource(responseHeader, responseHeader.getContentLength(), httpConnection);
              setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);

                      messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
                      try {
                        setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
                      } finally {
              messageHandler.onHeaderProcessed();
            }             
           
            break;

           
                    case BODY_TYPE_WEBSOCKET:
                        dataSource = new FullMessageBodyDataSource(responseHeader, 16, httpConnection);
                        setBodyDataSource(dataSource);
                       
                        response = new HttpResponse(responseHeader, dataSource);
                        response.removeHeader("Content-Length");

                        messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
                        try {
                            setMessageHandler(messageHandler);
                           
                            response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
                            rawData = parserBody(httpConnection, rawData);
                        } finally {
                            messageHandler.onHeaderProcessed();
                        }                          
                       
                        break;
           
           
          case BODY_TYPE_SIMPLE:
              dataSource = new SimpleMessageBodyDataSource(responseHeader, httpConnection);
                        setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);
           
            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
                    setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
            } finally {
              messageHandler.onHeaderProcessed();
            }
            break;
           
          case BODY_TYPE_MULTIPART_BYTERANGE:             
              dataSource = new MultipartByteRangeMessageBodyDataSource(httpConnection, responseHeader);
              setBodyDataSource(dataSource);
           
            response = new HttpResponse(responseHeader, dataSource);

            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
              setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
            } finally {
              messageHandler.onHeaderProcessed();
            }
            break;
           
           
          default// BODY_TYPE_CHUNKED
            dataSource = new FullMessageChunkedBodyDataSource(httpConnection, responseHeader);
              setBodyDataSource(dataSource);

            response = new HttpResponse(responseHeader, dataSource);
           
            messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
            try {
              setMessageHandler(messageHandler);
             
              response.getNonBlockingBody().setBodyDataReceiveTimeoutMillis(httpConnection.getBodyDataReceiveTimeoutMillis());
              rawData = parserBody(httpConnection, rawData);
View Full Code Here

        setState(RECEIVING_BODY);
       
        HttpResponse response = new HttpResponse(responseHeader, dataSource, true);

       
        IMessageHeaderHandler messageHeaderHandler = httpConnection.getMessageHeaderHandler(); // get it before disconnecting dataSource!
        if (messageHeaderHandler == null) {
            throw new IOException("no message handler set");
        }
       
        dataSource.parse(rawData);
        dataSource.onDisconnect();  
       
        IMessageHandler messageHandler = messageHeaderHandler.onMessageHeaderReceived(response);
        setMessageHandler(messageHandler);
        messageHandler.onHeaderProcessed();
  }
View Full Code Here

TOP

Related Classes of org.xlightweb.AbstractHttpConnection.IMessageHeaderHandler

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.