Package io.netty.handler.codec.http

Examples of io.netty.handler.codec.http.HttpMethod


   @Override
   public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception
   {
      FullHttpRequest request = (FullHttpRequest) msg;
      HttpMethod method = request.getMethod();
      // if we are a post then we send upstream, otherwise we are just being prompted for a response.
      if (method.equals(HttpMethod.POST ) )
      {
         ctx.fireChannelRead(ReferenceCountUtil.retain(((FullHttpRequest) msg).content()));
         // add a new response
         responses.put(new ResponseHolder(System.currentTimeMillis() + responseTime,
               new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)));
View Full Code Here


    private static FullHttpRequest createHttpRequest(int spdyVersion, SpdyHeadersFrame requestFrame)
            throws Exception {
        // Create the first line of the request from the name/value pairs
        SpdyHeaders headers     = requestFrame.headers();
        HttpMethod  method      = HttpMethod.valueOf(headers.get(METHOD));
        String      url         = headers.get(PATH);
        HttpVersion httpVersion = HttpVersion.valueOf(headers.get(VERSION));
        headers.remove(METHOD);
        headers.remove(PATH);
        headers.remove(VERSION);
View Full Code Here

            throw new NullPointerException("request");
        }
        if (charset == null) {
            throw new NullPointerException("charset");
        }
        HttpMethod method = request.method();
        if (!(method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)
                || method.equals(HttpMethod.PATCH) || method.equals(HttpMethod.OPTIONS))) {
            throw new ErrorDataEncoderException("Cannot create a Encoder if not a POST");
        }
        this.request = request;
        this.charset = charset;
        this.factory = factory;
View Full Code Here

  @Override
  public synchronized HttpServerRequest setExpectMultipart(boolean expect) {
    if (expect && decoder == null) {
      String contentType = request.headers().get(HttpHeaders.Names.CONTENT_TYPE);
      if (contentType != null) {
        HttpMethod method = request.getMethod();
        String lowerCaseContentType = contentType.toLowerCase();
        isURLEncoded = lowerCaseContentType.startsWith(HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED);
        if ((lowerCaseContentType.startsWith(HttpHeaders.Values.MULTIPART_FORM_DATA) || isURLEncoded) &&
            (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PATCH))) {
          decoder = new HttpPostRequestDecoder(new DataFactory(), request);
        }
      }
    } else {
      decoder = null;
View Full Code Here

        boolean useSSl = isSecure(uri) && !useProxy;

        // some headers are only set when performing the first request
        HttpHeaders headers = future.getNettyRequest().getHttpRequest().headers();
        Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();
        HttpMethod method = future.getNettyRequest().getHttpRequest().getMethod();
        requestFactory.addAuthorizationHeader(headers, requestFactory.firstRequestOnlyAuthorizationHeader(request, uri, proxy, realm));
        requestFactory.setProxyAuthorizationHeader(headers, requestFactory.firstRequestOnlyProxyAuthorizationHeader(request, proxy, method));

        // Do not throw an exception when we need an extra connection for a
        // redirect
View Full Code Here

            headers.set(HttpHeaders.Names.PROXY_AUTHORIZATION, proxyAuthorizationHeader);
    }

    public NettyRequest newNettyRequest(Request request, Uri uri, boolean forceConnect, ProxyServer proxyServer) throws IOException {

        HttpMethod method = forceConnect ? HttpMethod.CONNECT : HttpMethod.valueOf(request.getMethod());
        HttpVersion httpVersion = method == HttpMethod.CONNECT ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1;
        String requestUri = requestUri(uri, proxyServer, method);

        NettyBody body = body(request, method);
View Full Code Here

        name = name.trim().toUpperCase();
        if (name.length() == 0) {
            throw new IllegalArgumentException("empty name");
        }

        HttpMethod result = methodMap.get(name);
        if (result != null) {
            return result;
        } else {
            return new HttpMethod(name);
        }
    }
View Full Code Here

    }

    private HttpRequest createHttpRequest(SpdyHeaderBlock requestFrame)
            throws Exception {
        // Create the first line of the request from the name/value pairs
        HttpMethod  method  = SpdyHeaders.getMethod(requestFrame);
        String      url     = SpdyHeaders.getUrl(requestFrame);
        HttpVersion version = SpdyHeaders.getVersion(requestFrame);
        SpdyHeaders.removeMethod(requestFrame);
        SpdyHeaders.removeUrl(requestFrame);
        SpdyHeaders.removeVersion(requestFrame);
View Full Code Here

    }

    WebSocketServerHandshakerFactory factory = new WebSocketServerHandshakerFactory(wsPath.toString(), null, false, maxLength);

    Request request = context.getRequest();
    HttpMethod method = valueOf(request.getMethod().getName());
    FullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, request.getUri());
    nettyRequest.headers().add(SEC_WEBSOCKET_VERSION, request.getHeaders().get(SEC_WEBSOCKET_VERSION));
    nettyRequest.headers().add(SEC_WEBSOCKET_KEY, request.getHeaders().get(SEC_WEBSOCKET_KEY));

    final WebSocketServerHandshaker handshaker = factory.newHandshaker(nettyRequest);
View Full Code Here

        URL u = getURL();
        String uri = u.getPathAndQuery();
        if (uri.isEmpty()) {
            uri = "/";
        }
        HttpMethod mth = HttpMethod.valueOf(method.name());
        DefaultHttpRequest h = body == null
                ? new DefaultHttpRequest(version, mth, uri)
                : new DefaultFullHttpRequest(version, mth, uri, body);
        for (Entry<?> e : entries) {
            e.addTo(h.headers());
View Full Code Here

TOP

Related Classes of io.netty.handler.codec.http.HttpMethod

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.