本文整理匯總了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;
}