当前位置: 首页>>代码示例>>Java>>正文


Java FullHttpRequest.getUri方法代码示例

本文整理汇总了Java中io.netty.handler.codec.http.FullHttpRequest.getUri方法的典型用法代码示例。如果您正苦于以下问题:Java FullHttpRequest.getUri方法的具体用法?Java FullHttpRequest.getUri怎么用?Java FullHttpRequest.getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.handler.codec.http.FullHttpRequest的用法示例。


在下文中一共展示了FullHttpRequest.getUri方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleNonProxyRequest

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
protected HttpResponse handleNonProxyRequest(FullHttpRequest req) {
	String uri = req.getUri();
	if ("/version".equals(uri)) {
		if (HttpMethod.GET.equals(req.getMethod())) {
			JsonObject jsonObj = new JsonObject();
			jsonObj.addProperty("name", m_appConfig.getAppName());
			jsonObj.addProperty("version", m_appConfig.getAppVersion());
			byte[] content = jsonObj.toString().getBytes(CharsetUtil.UTF_8);
			DefaultFullHttpResponse resp = new DefaultFullHttpResponse(
					HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
					Unpooled.copiedBuffer(content));
			HttpHeaders.setKeepAlive(resp, false);
			HttpHeaders.setHeader(resp, HttpHeaders.Names.CONTENT_TYPE,
					"application/json");
			HttpHeaders.setContentLength(resp, content.length);
			return resp;
		}
	}
	
	return RESPONSE_404;
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:22,代码来源:NettyRequestProxyFilter.java

示例2: getRequestURI

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
private String getRequestURI(FullHttpRequest request) {
	String uri = request.getUri();
	if (uri.startsWith("/")) {
		String host = HttpHeaders.getHost(request);
		if (host != null && !host.isEmpty()) {
			uri = "https://" + host + uri;
		}
	}
	return uri;
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:11,代码来源:RequestKeyGenerator.java

示例3: populateCamelHeaders

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Override
public void populateCamelHeaders(FullHttpRequest request, Map<String, Object> headers, Exchange exchange, NettyHttpConfiguration configuration) throws Exception {
    super.populateCamelHeaders(request, headers, exchange, configuration);

    String path = request.getUri();
    if (path == null) {
        return;
    }

    // skip the scheme/host/port etc, as we only want the context-path
    URI uri = new URI(path);
    path = uri.getPath();

    // in the endpoint the user may have defined rest {} placeholders
    // so we need to map those placeholders with data from the incoming request context path

    String consumerPath = configuration.getPath();

    if (useRestMatching(consumerPath)) {

        // split using single char / is optimized in the jdk
        String[] paths = path.split("/");
        String[] consumerPaths = consumerPath.split("/");

        for (int i = 0; i < consumerPaths.length; i++) {
            if (paths.length < i) {
                break;
            }
            String p1 = consumerPaths[i];
            if (p1.startsWith("{") && p1.endsWith("}")) {
                String key = p1.substring(1, p1.length() - 1);
                String value = paths[i];
                if (value != null) {
                    NettyHttpHelper.appendHeader(headers, key, value);
                }
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:RestNettyHttpBinding.java

示例4: createEventMetadata

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
private EventMetadata createEventMetadata(FullHttpRequest request) {
   String querystring = null;
   String requestURI = request.getUri();
   int index = request.getUri().indexOf("?");
   if (index > 0) {
      requestURI = request.getUri().substring(0, index);
      querystring = request.getUri().substring(index + 1);
   }

   if (ProxyUtils.isCONNECT(request)) {

   }
   String host = request.headers().get("host").toLowerCase();
   String targetUrl = requestURI;
   // if (!requestURI.startsWith("http") &&
   // !requestURI.toLowerCase().startsWith(host)) {
   // targetUrl = host + requestURI;
   // }

   if (!requestURI.startsWith("http://") && !requestURI.startsWith("https://")
         && !requestURI.toLowerCase().startsWith(host)) {
      targetUrl = "https://" + host + requestURI;
   }

   String methodName = request.getMethod().toString();

   ControlEvent controlEvent;
   if (Context.requestScope().getProperty(InternalRequestScope.CONTROLEVENT) != null) {
      controlEvent = (ControlEvent) Context.requestScope().getProperty(InternalRequestScope.CONTROLEVENT);
   } else if (request.headers().get(Headers.CIBET_CONTROLEVENT.name()) != null) {
      controlEvent = ControlEvent.valueOf(request.headers().get(Headers.CIBET_CONTROLEVENT.name()));

   } else {
      controlEvent = ControlEvent.INVOKE;
   }

   if (log.isDebugEnabled()) {
      log.debug("control " + controlEvent + " of " + methodName + " " + targetUrl + " for tenant "
            + Context.internalSessionScope().getTenant());
   }

   HttpRequestData httpData = new HttpRequestData(host, querystring, requestURI);
   HttpRequestResource resource = new HttpRequestResource(targetUrl, methodName, httpData);
   addHeaders(request.headers(), resource);

   String contentType = request.headers().get("Content-Type");
   addParameters(querystring, content(request.content()), contentType, resource);

   resource.setInvoker("localhost");
   EventMetadata metadata = new EventMetadata(SENSOR_NAME, controlEvent, resource);
   metadata.setProxyConfig(proxyConfig);
   return metadata;
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:54,代码来源:CibetProxy.java

示例5: execute

import io.netty.handler.codec.http.FullHttpRequest; //导入方法依赖的package包/类
@Nullable
@Override
public String execute(@NotNull QueryStringDecoder urlDecoder, @NotNull FullHttpRequest request, @NotNull ChannelHandlerContext context) throws IOException {
  BuildNumber build = ApplicationInfo.getInstance().getBuild();
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  BufferExposingByteArrayOutputStream byteOut = new BufferExposingByteArrayOutputStream();
  JsonWriter writer = createJsonWriter(byteOut);
  writer.beginObject();

  ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
  String appName = appInfo.getFullApplicationName();
  if (!PlatformUtils.isIdeaUltimate()) {
    String productName = ApplicationNamesInfo.getInstance().getProductName();
    appName = appName.replace(productName + " (" + productName + ")", productName);
    if (appName.startsWith("JetBrains ")) {
      appName = appName.substring("JetBrains ".length());
    }
  }

  writer.name("name").value(appName);
  writer.name("productName").value(ApplicationNamesInfo.getInstance().getProductName());
  writer.name("baselineVersion").value(build.getBaselineVersion());
  if (build.getBuildNumber() != Integer.MAX_VALUE) {
    writer.name("buildNumber").value(build.getBuildNumber());
  }

  if (getBooleanParameter("registeredFileTypes", urlDecoder)) {
    writer.name("registeredFileTypes").beginArray();
    for (FileType fileType : FileTypeRegistry.getInstance().getRegisteredFileTypes()) {
      writer.beginObject();
      writer.name("name").value(fileType.getName());
      writer.name("description").value(fileType.getDescription());
      writer.name("isBinary").value(fileType.isBinary());
      writer.endObject();
    }
    writer.endArray();
  }

  String uri = request.getUri();
  if (uri != null && uri.endsWith("?more")) {
    writer.name("vendor").value(appInfo.getCompanyName());
    writer.name("isEAP").value(appInfo.isEAP());
    writer.name("productCode").value(appInfo.getBuild().getProductCode());
    writer.name("buildDate").value(appInfo.getBuildDate().getTime().getTime());
    writer.name("isSnapshot").value(appInfo.getBuild().isSnapshot());
    writer.name("configPath").value(PathManager.getConfigPath());
    writer.name("systemPath").value(PathManager.getSystemPath());
    writer.name("binPath").value(PathManager.getBinPath());
    writer.name("logPath").value(PathManager.getLogPath());
    writer.name("homePath").value(PathManager.getHomePath());
  }

  writer.endObject();
  writer.close();
  send(byteOut, request, context);
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:AboutHttpService.java


注:本文中的io.netty.handler.codec.http.FullHttpRequest.getUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。