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

Examples of org.jboss.netty.handler.codec.http.HttpRequest.headers()


        // set the content type in the response.
        String contentType = MessageHelper.getContentType(message);
        if (contentType != null) {
            // set content-type
            request.headers().set(HttpHeaders.Names.CONTENT_TYPE, contentType);
            LOG.trace("Content-Type: {}", contentType);
        }

        // must include HOST header as required by HTTP 1.1
        // use URI as its faster than URL (no DNS lookup)
View Full Code Here


        // must include HOST header as required by HTTP 1.1
        // use URI as its faster than URL (no DNS lookup)
        URI u = new URI(uri);
        String host = u.getHost();
        request.headers().set(HttpHeaders.Names.HOST, host);
        LOG.trace("Host: {}", host);

        // configure connection to accordingly to keep alive configuration
        // favor using the header from the message
        String connection = message.getHeader(HttpHeaders.Names.CONNECTION, String.class);
View Full Code Here

                connection = HttpHeaders.Values.KEEP_ALIVE;
            } else {
                connection = HttpHeaders.Values.CLOSE;
            }
        }
        request.headers().set(HttpHeaders.Names.CONNECTION, connection);
        LOG.trace("Connection: {}", connection);

        return request;
    }
View Full Code Here

        String path = url.getPath();
        if (url.getQuery() != null && url.getQuery().length() > 0) {
            path = url.getPath() + "?" + url.getQuery();
        }
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
        request.headers().add(Names.UPGRADE, Values.WEBSOCKET);
        request.headers().add(Names.CONNECTION, Values.UPGRADE);
        request.headers().add(Names.HOST, url.getHost());
        request.headers().add(Names.ORIGIN, "http://" + url.getHost());
        event.getChannel().write(request);
        ctx.getPipeline().replace("encoder", "ws-encoder", new WebSocket00FrameEncoder());
View Full Code Here

        if (url.getQuery() != null && url.getQuery().length() > 0) {
            path = url.getPath() + "?" + url.getQuery();
        }
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
        request.headers().add(Names.UPGRADE, Values.WEBSOCKET);
        request.headers().add(Names.CONNECTION, Values.UPGRADE);
        request.headers().add(Names.HOST, url.getHost());
        request.headers().add(Names.ORIGIN, "http://" + url.getHost());
        event.getChannel().write(request);
        ctx.getPipeline().replace("encoder", "ws-encoder", new WebSocket00FrameEncoder());
        this.channel = event.getChannel();
View Full Code Here

            path = url.getPath() + "?" + url.getQuery();
        }
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
        request.headers().add(Names.UPGRADE, Values.WEBSOCKET);
        request.headers().add(Names.CONNECTION, Values.UPGRADE);
        request.headers().add(Names.HOST, url.getHost());
        request.headers().add(Names.ORIGIN, "http://" + url.getHost());
        event.getChannel().write(request);
        ctx.getPipeline().replace("encoder", "ws-encoder", new WebSocket00FrameEncoder());
        this.channel = event.getChannel();
    }
View Full Code Here

        }
        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
        request.headers().add(Names.UPGRADE, Values.WEBSOCKET);
        request.headers().add(Names.CONNECTION, Values.UPGRADE);
        request.headers().add(Names.HOST, url.getHost());
        request.headers().add(Names.ORIGIN, "http://" + url.getHost());
        event.getChannel().write(request);
        ctx.getPipeline().replace("encoder", "ws-encoder", new WebSocket00FrameEncoder());
        this.channel = event.getChannel();
    }
View Full Code Here

 
  @Test
  public void httpCORSIgnored() {
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.GET, "/api/v1/version");
    req.headers().add(HttpHeaders.ORIGIN, "42.com");

    handleHttpRpc(req,
      new Answer<ChannelFuture>() {
        public ChannelFuture answer(final InvocationOnMock args)
          throws Throwable {
View Full Code Here

 
  @Test
  public void httpCORSPublicSimple() {
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.GET, "/api/v1/version");
    req.headers().add(HttpHeaders.ORIGIN, "42.com");

    handleHttpRpc(req,
      new Answer<ChannelFuture>() {
        public ChannelFuture answer(final InvocationOnMock args)
          throws Throwable {
View Full Code Here

 
  @Test
  public void httpCORSSpecificSimple() {
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.GET, "/api/v1/version");
    req.headers().add(HttpHeaders.ORIGIN, "42.com");

    handleHttpRpc(req,
      new Answer<ChannelFuture>() {
        public ChannelFuture answer(final InvocationOnMock args)
          throws Throwable {
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.