本文整理汇总了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;
}
示例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;
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}