當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpRequest.getUri方法代碼示例

本文整理匯總了Java中io.netty.handler.codec.http.HttpRequest.getUri方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequest.getUri方法的具體用法?Java HttpRequest.getUri怎麽用?Java HttpRequest.getUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.handler.codec.http.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.getUri方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRequestURL

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
private String getRequestURL(Channel channel,HttpRequest req){
    StringBuffer url = new StringBuffer();
    String scheme = isSecure(channel)?"https":"http";
    InetSocketAddress addr = (InetSocketAddress)channel.localAddress();
    int port = addr.getPort();
    String urlPath = req.getUri();


    url.append(scheme); // http, https
    url.append("://");
    url.append(EnFactory.getEnHost().getHostAddress());
    if (("http".equalsIgnoreCase(scheme) && port != 80)
            || ("https".equalsIgnoreCase(scheme) && port != 443)) {
        url.append(':');
        url.append(port);
    }

    url.append(urlPath);
    return url.toString();
}
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:21,代碼來源:VINettyHandler.java

示例2: filterRequest

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public HttpResponse filterRequest(HttpRequest httpRequest, HttpMessageContents httpMessageContents, HttpMessageInfo httpMessageInfo) {
    replayingState.addHttpRequestToQueue(httpMessageInfo.getOriginalRequest());
    replayingState.setHttpLock(false);

    for (ConditionsUpdater conditionsUpdater: conditionsUpdaters) {
        if (conditionsUpdater.shouldUpdate().test(httpRequest)) {
            try {
                URL url = new URL(httpRequest.getUri());
                String event = url.getQuery();
                conditionsUpdater.updater().update(replayingState, event);
            } catch (MalformedURLException e) {
                logger.error(e.getMessage(), e);
            }
        }
    }

    return null;
}
 
開發者ID:hristo-vrigazov,項目名稱:bromium,代碼行數:20,代碼來源:ReplayRequestFilter.java

示例3: channelRead0

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void channelRead0(final ChannelHandlerContext ctx,
                         final HttpRequest req) throws Exception {
  Preconditions.checkArgument(req.getUri().startsWith(WEBHDFS_PREFIX));
  QueryStringDecoder queryString = new QueryStringDecoder(req.getUri());
  params = new ParameterParser(queryString, conf);
  DataNodeUGIProvider ugiProvider = new DataNodeUGIProvider(params);
  ugi = ugiProvider.ugi();
  path = params.path();

  injectToken();
  ugi.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      handle(ctx, req);
      return null;
    }
  });
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:WebHdfsHandler.java

示例4: getParameter

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
public static String getParameter(HttpRequest req, String name) {
	QueryStringDecoder decoderQuery = new QueryStringDecoder(req.getUri());
	Map<String, List<String>> uriAttributes = decoderQuery.parameters();

	return uriAttributes.containsKey(name) ? uriAttributes.get(name).get(0)
			: null;
}
 
開發者ID:osswangxining,項目名稱:mqttserver,代碼行數:8,代碼來源:HttpSessionStore.java

示例5: Bootstrap

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void channelRead0
  (final ChannelHandlerContext ctx, final HttpRequest req) {
  uri = req.getUri();
  final Channel client = ctx.channel();
  Bootstrap proxiedServer = new Bootstrap()
    .group(client.eventLoop())
    .channel(NioSocketChannel.class)
    .handler(new ChannelInitializer<SocketChannel>() {
      @Override
      protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline p = ch.pipeline();
        p.addLast(new HttpRequestEncoder(), new Forwarder(uri, client));
      }
    });
  ChannelFuture f = proxiedServer.connect(host);
  proxiedChannel = f.channel();
  f.addListener(new ChannelFutureListener() {
    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
      if (future.isSuccess()) {
        ctx.channel().pipeline().remove(HttpResponseEncoder.class);
        HttpRequest newReq = new DefaultFullHttpRequest(HTTP_1_1,
          req.getMethod(), req.getUri());
        newReq.headers().add(req.headers());
        newReq.headers().set(CONNECTION, Values.CLOSE);
        future.channel().writeAndFlush(newReq);
      } else {
        DefaultHttpResponse resp = new DefaultHttpResponse(HTTP_1_1,
          INTERNAL_SERVER_ERROR);
        resp.headers().set(CONNECTION, Values.CLOSE);
        LOG.info("Proxy " + uri + " failed. Cause: ", future.cause());
        ctx.writeAndFlush(resp).addListener(ChannelFutureListener.CLOSE);
        client.close();
      }
    }
  });
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:39,代碼來源:SimpleHttpProxyHandler.java

示例6: convert

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public Optional<Map<String, String>> convert(HttpRequest httpRequest) throws MalformedURLException, UnsupportedEncodingException {
    String requestUri = httpRequest.getUri();

    if (!requestUri.startsWith(baseUrl)) {
        throw new IllegalArgumentException("I am not responsible for this request URL: " + requestUri);
    }

    if (requestUri.endsWith(LINK_INTERCEPTOR_MARKER)) {
        httpRequest.setUri(requestUri.split(LINK_INTERCEPTOR_MARKER)[0]);
        return Optional.empty();
    }

    for (ApplicationActionConfiguration applicationActionConfiguration: applicationActionConfigurations) {
        ParameterConfiguration urlParameterConfiguration = applicationActionConfiguration
                .getWebDriverAction()
                .getParametersConfiguration()
                .get(Constants.PAGE);

        // first the easy case; if the value is hardcoded in the configuration
        // and the current url matches, then we have found the action
        if (!urlParameterConfiguration.isExposed()) {
            String expectedUrl = baseUrl + urlParameterConfiguration.getValue();
            if (expectedUrl.equals(requestUri)) {
                return Optional.of(ImmutableMap.of(EVENT, applicationActionConfiguration.getName()));
            }
        } else {
            String[] urlParts = requestUri.split(baseUrl);
            if (urlParts.length < 2) {
                return Optional.empty();
            }
            String urlContinuation = urlParts[1];
            return Optional.of(ImmutableMap.of(
                    EVENT, applicationActionConfiguration.getName(),
                    urlParameterConfiguration.getAlias(), urlContinuation
            ));
        }
    }

    return Optional.empty();
}
 
開發者ID:hristo-vrigazov,項目名稱:bromium,代碼行數:42,代碼來源:RequestToPageLoadingEventConverter.java

示例7: getReqParams

import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
public final static Map<String,Object> getReqParams(HttpRequest req,String reqIP){

        Map<String,Object> params = new HashMap<>();
        QueryStringDecoder decoder = new QueryStringDecoder(req.getUri());


        for(Map.Entry<String,List<String>> para :decoder.parameters().entrySet()){

            params.put(para.getKey(),para.getValue().get(0));
        }
        params.put("req_ip",reqIP);
        return params;
    }
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:14,代碼來源:NettyUtils.java


注:本文中的io.netty.handler.codec.http.HttpRequest.getUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。