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

Examples of org.jboss.netty.handler.codec.http.DefaultHttpResponse.addHeader()


   * @param request
   */
  public static HttpResponse copyHeaders(HttpResponse response) {
    HttpResponse copy = new DefaultHttpResponse(response.getProtocolVersion(), response.getStatus());
    for (String h : response.getHeaderNames()) {
      copy.addHeader(h, response.getHeader(h));
    }
    return copy;
  }
 
  /**
 
View Full Code Here


     */
    // Create the WebSocket handshake response.
        HttpResponse res = new DefaultHttpResponse(
                HTTP_1_1,
                new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
        res.addHeader(Names.UPGRADE, WEBSOCKET);
        res.addHeader(CONNECTION, Values.UPGRADE);

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

    // Create the WebSocket handshake response.
        HttpResponse res = new DefaultHttpResponse(
                HTTP_1_1,
                new HttpResponseStatus(101, "Web Socket Protocol Handshake"));
        res.addHeader(Names.UPGRADE, WEBSOCKET);
        res.addHeader(CONNECTION, Values.UPGRADE);

        // Fill in the headers and contents depending on handshake method.
        if (request.containsHeader(SEC_WEBSOCKET_KEY1) &&
            request.containsHeader(SEC_WEBSOCKET_KEY2)) {
            // New handshake method with a challenge:
View Full Code Here

        // Fill in the headers and contents depending on handshake method.
        if (request.containsHeader(SEC_WEBSOCKET_KEY1) &&
            request.containsHeader(SEC_WEBSOCKET_KEY2)) {
            // New handshake method with a challenge:
            res.addHeader(SEC_WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(SEC_WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(SEC_WEBSOCKET_PROTOCOL, protocol);
            }
View Full Code Here

        // Fill in the headers and contents depending on handshake method.
        if (request.containsHeader(SEC_WEBSOCKET_KEY1) &&
            request.containsHeader(SEC_WEBSOCKET_KEY2)) {
            // New handshake method with a challenge:
            res.addHeader(SEC_WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(SEC_WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(SEC_WEBSOCKET_PROTOCOL, protocol);
            }
View Full Code Here

            // New handshake method with a challenge:
            res.addHeader(SEC_WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(SEC_WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(SEC_WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(SEC_WEBSOCKET_PROTOCOL, protocol);
            }

            // Calculate the answer of the challenge.
            String key1 = request.getHeader(SEC_WEBSOCKET_KEY1);
            String key2 = request.getHeader(SEC_WEBSOCKET_KEY2);
View Full Code Here

        log.error("Caught", e); //should never ever happen
      }
          
        } else {
            // Old handshake method with no challenge:
            res.addHeader(WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(WEBSOCKET_PROTOCOL, protocol);
            }
View Full Code Here

      }
          
        } else {
            // Old handshake method with no challenge:
            res.addHeader(WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(WEBSOCKET_PROTOCOL, protocol);
            }
        }
View Full Code Here

            // Old handshake method with no challenge:
            res.addHeader(WEBSOCKET_ORIGIN, request.getHeader(ORIGIN));
            res.addHeader(WEBSOCKET_LOCATION, getWebSocketLocation(request));
            String protocol = request.getHeader(WEBSOCKET_PROTOCOL);
            if (protocol != null) {
                res.addHeader(WEBSOCKET_PROTOCOL, protocol);
            }
        }

        // Upgrade the connection and send the handshake response.
        ChannelPipeline p = this.getChannelConnection().getChannel().getPipeline();
View Full Code Here

            HttpResponseStatus.valueOf(status));
   
    List<KeyValuePair<String, String>> headers = ev.getHeaders();
    for (KeyValuePair<String, String> header : headers)
    {
      response.addHeader(header.getName(), header.getValue());
    }
   
    if (null == response.getHeader(HttpHeaders.Names.CONTENT_LENGTH))
    {
      response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, ""
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.