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

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


    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception {
        if (!handshakeCompleted) {
            HttpResponse response = (HttpResponse) event.getMessage();
            final HttpResponseStatus status = new HttpResponseStatus(101, "Web Socket Protocol Handshake");
            final boolean validStatus = response.getStatus().equals(status);
            final boolean validUpgrade = response.headers().get(Names.UPGRADE).equals(Values.WEBSOCKET);
            final boolean validConnection = response.headers().get(Names.CONNECTION).equals(Values.UPGRADE);
            if (!validStatus || !validUpgrade || !validConnection) {
                throw new NettyWebSocketException("Invalid handshake response");
View Full Code Here


    @Override
    public void prepareHandshakeResponse(NettyWebSocketConnection webSocketConnection) {
        webSocketConnection.setVersion("HIXIE-76");

        res.setStatus(new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
        res.addHeader(UPGRADE, WEBSOCKET);
        res.addHeader(CONNECTION, UPGRADE);
        res.addHeader(SEC_WEBSOCKET_ORIGIN, req.getHeader(ORIGIN));
        res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketLocation(req));
        String protocol = req.getHeader(SEC_WEBSOCKET_PROTOCOL);
View Full Code Here

            return;
        }

        String accept = Base64.encode(sha1(key + ACCEPT_GUID));

        res.setStatus(new HttpResponseStatus(101, "Switching Protocols"));
        res.addHeader(UPGRADE, WEBSOCKET.toLowerCase());
        res.addHeader(CONNECTION, UPGRADE);
        res.addHeader(SEC_WEBSOCKET_ACCEPT, accept);

        String webSocketProtocol = req.getHeader(SEC_WEBSOCKET_PROTOCOL);
View Full Code Here

    }

    @Override
    public void prepareHandshakeResponse(NettyWebSocketConnection webSocketConnection) {
        webSocketConnection.setVersion("HIXIE-75");
        res.setStatus(new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
        res.addHeader(UPGRADE, WEBSOCKET);
        res.addHeader(CONNECTION, HttpHeaders.Values.UPGRADE);
        String origin = req.getHeader(ORIGIN);
        if (origin != null) {
            res.addHeader(WEBSOCKET_ORIGIN, origin);
View Full Code Here

            HttpHeaders.Values.WEBSOCKET.equalsIgnoreCase(req.getHeader(HttpHeaders.Names.UPGRADE))) {

            // Create the WebSocket handshake response.
            HttpResponse res = new DefaultHttpResponse(
                    HttpVersion.HTTP_1_1,
                    new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
            res.addHeader(HttpHeaders.Names.UPGRADE, HttpHeaders.Values.WEBSOCKET);
            res.addHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.UPGRADE);
            res.addHeader(HttpHeaders.Names.WEBSOCKET_ORIGIN, req.getHeader(HttpHeaders.Names.ORIGIN));
            res.addHeader(HttpHeaders.Names.WEBSOCKET_LOCATION, getWebSocketLocation(req));
            String protocol = req.getHeader(HttpHeaders.Names.WEBSOCKET_PROTOCOL);
View Full Code Here

    {
      HttpResponse nettyResponse = (HttpResponse) msg;

      RestResponseBuilder builder = new RestResponseBuilder();

      HttpResponseStatus status = nettyResponse.getStatus();
      builder.setStatus(status.getCode());

      for (Map.Entry<String, String> e : nettyResponse.getHeaders())
      {
        builder.unsafeAddHeaderValue(e.getKey(), e.getValue());
      }
View Full Code Here

    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception
    {
        if (msg instanceof org.jboss.resteasy.spi.HttpResponse) {
            NettyHttpResponse nettyResponse = (NettyHttpResponse) msg;
            // Build the response object.
            HttpResponseStatus status = HttpResponseStatus.valueOf(nettyResponse.getStatus());
            HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);

            for (Map.Entry<String, List<Object>> entry : nettyResponse.getOutputHeaders().entrySet())
            {
               String key = entry.getKey();
View Full Code Here

       if (committed)
       {
           throw new IllegalStateException();
       }
      
       HttpResponseStatus responseStatus = null;
       if (message != null)
       {
           responseStatus = new HttpResponseStatus(status, message);
       }
       else
       {
           responseStatus = HttpResponseStatus.valueOf(status);
       }
View Full Code Here

         return;
      } else if (Values.UPGRADE.equalsIgnoreCase(req.getHeader(CONNECTION)) &&
            WEBSOCKET.equalsIgnoreCase(req.getHeader(Names.UPGRADE))) {
         // Serve the WebSocket handshake request.
         // Create the WebSocket handshake response.
         HttpResponse res = new DefaultHttpResponse(HTTP_1_1, new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
         res.addHeader(Names.UPGRADE, Values.WEBSOCKET);
         res.addHeader(Names.CONNECTION, Values.UPGRADE);

         // Fill in the headers and contents depending on handshake method.
         if (req.containsHeader(Names.SEC_WEBSOCKET_KEY1) &&
View Full Code Here

         return;
      } else if (Values.UPGRADE.equalsIgnoreCase(req.getHeader(CONNECTION)) &&
            WEBSOCKET.equalsIgnoreCase(req.getHeader(Names.UPGRADE))) {
         // Serve the WebSocket handshake request.
         // Create the WebSocket handshake response.
         HttpResponse res = new DefaultHttpResponse(HTTP_1_1, new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
         res.addHeader(Names.UPGRADE, Values.WEBSOCKET);
         res.addHeader(Names.CONNECTION, Values.UPGRADE);

         // Fill in the headers and contents depending on handshake method.
         if (req.containsHeader(Names.SEC_WEBSOCKET_KEY1) &&
View Full Code Here

TOP

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

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.