- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeRequest.getHeader()
方法的一些代码示例,展示了YokeRequest.getHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeRequest.getHeader()
方法的具体详情如下:
包路径:com.jetdrone.vertx.yoke.middleware.YokeRequest
类名称:YokeRequest
方法名:getHeader
[英]Allow getting headers in a generified way.
[中]
代码示例来源:origin: pmlopes/yoke
private HttpServerResponse addCorsResponseHeaders(final YokeRequest request, final YokeResponse response)
{
final String origin = request.getHeader(ORIGIN);
return addCorsResponseHeaders(origin, response);
}
代码示例来源:origin: pmlopes/yoke
private boolean isPreflightRequest(final YokeRequest request)
{
return OPTIONS.name().equals(request.method())
&& (request.getHeader(ACCESS_CONTROL_REQUEST_HEADERS) != null || request.getHeader(ACCESS_CONTROL_REQUEST_METHOD) != null);
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
boolean isSecure = (request.isSSL())
|| ("on".equals(request.getHeader("front-end-https")))
|| ("https".equals(request.getHeader("x-forwarded-proto")));
if (isSecure) {
request.response().putHeader("Strict-Transport-Security", header);
}
next.handle(null);
}
}
代码示例来源:origin: pmlopes/yoke
public static WebClient detect(YokeRequest req) {
return detect(req.getHeader("User-Agent"));
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
String host = request.getHeader("host");
if (host == null) {
next.handle(null);
} else {
boolean match = false;
for (String h : host.split(":")) {
if (regex.matcher(h).find()) {
match = true;
break;
}
}
if (match) {
handler.handle(request);
} else {
next.handle(null);
}
}
}
}
代码示例来源:origin: pmlopes/yoke
/** Read the default locale for this request
*
* @return Locale (best match if more than one)
*/
public Locale locale() {
String languages = getHeader("Accept-Language");
if (languages != null) {
// parse
String[] acceptLanguages = languages.split(" *, *");
// sort on quality
Arrays.sort(acceptLanguages, ACCEPT_X_COMPARATOR);
String bestLanguage = acceptLanguages[0];
int idx = bestLanguage.indexOf(';');
if (idx != -1) {
bestLanguage = bestLanguage.substring(0, idx).trim();
}
String[] parts = bestLanguage.split("_|-");
switch (parts.length) {
case 3: return new Locale(parts[0], parts[1], parts[2]);
case 2: return new Locale(parts[0], parts[1]);
case 1: return new Locale(parts[0]);
}
}
return Locale.getDefault();
}
代码示例来源:origin: pmlopes/yoke
/** Returns the array of accept-? ordered by quality.
*/
public List<String> sortedHeader(@NotNull final String header) {
String accept = getHeader(header);
// accept anything when accept is not present
if (accept == null) {
return Collections.emptyList();
}
// parse
String[] items = accept.split(" *, *");
// sort on quality
Arrays.sort(items, ACCEPT_X_COMPARATOR);
List<String> list = new ArrayList<>(items.length);
for (String item : items) {
// find any ; e.g.: "application/json;q=0.8"
int space = item.indexOf(';');
if (space != -1) {
list.add(item.substring(0, space));
} else {
list.add(item);
}
}
return list;
}
代码示例来源:origin: pmlopes/yoke
/** Allow getting headers in a generified way and return defaultValue if the key does not exist.
*
* @param name The key to get
* @param defaultValue value returned when the key does not exist
* @return {String} The found object
*/
public String getHeader(@NotNull final String name, String defaultValue) {
if (headers().contains(name)) {
return getHeader(name);
} else {
return defaultValue;
}
}
代码示例来源:origin: pmlopes/yoke
String ct = getHeader("Content-Type");
if (ct == null) {
return false;
代码示例来源:origin: pmlopes/yoke
/** Check if the given type(s) is acceptable, returning the best match when true, otherwise null, in which
* case you should respond with 406 "Not Acceptable".
*
* The type value must be a single mime type string such as "application/json" and is validated by checking
* if the request string starts with it.
*/
public String accepts(@NotNull final String... types) {
String accept = getHeader("Accept");
// accept anything when accept is not present
if (accept == null) {
return types[0];
}
// parse
String[] acceptTypes = accept.split(" *, *");
// sort on quality
Arrays.sort(acceptTypes, ACCEPT_X_COMPARATOR);
for (String senderAccept : acceptTypes) {
String[] sAccept = splitMime(senderAccept);
for (String appAccept : types) {
String[] aAccept = splitMime(appAccept);
if (
(sAccept[0].equals(aAccept[0]) || "*".equals(sAccept[0]) || "*".equals(aAccept[0])) &&
(sAccept[1].equals(aAccept[1]) || "*".equals(sAccept[1]) || "*".equals(aAccept[1]))) {
return senderAccept;
}
}
}
return null;
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
String cookieHeader = request.getHeader("cookie");
if (cookieHeader != null) {
Set<Cookie> nettyCookies = CookieDecoder.decode(cookieHeader);
Set<YokeCookie> cookies = new TreeSet<>();
for (Cookie cookie : nettyCookies) {
YokeCookie yokeCookie = new YokeCookie(cookie, mac);
String value = yokeCookie.getUnsignedValue();
// value cannot be null in a cookie if the signature is mismatch then this value will be null
// in that case the cookie has been tampered
if (value == null) {
next.handle(400);
return;
}
cookies.add(yokeCookie);
}
request.setCookies(cookies);
}
next.handle(null);
}
}
代码示例来源:origin: pmlopes/yoke
/** Returns the ip address of the client, when trust-proxy is true (default) then first look into X-Forward-For
* Header */
public String ip() {
Boolean trustProxy = (Boolean) context.get("trust-proxy");
if (trustProxy != null && trustProxy) {
String xForwardFor = getHeader("x-forward-for");
if (xForwardFor != null) {
String[] ips = xForwardFor.split(" *, *");
if (ips.length > 0) {
return ips[0];
}
}
}
return request.remoteAddress().host();
}
代码示例来源:origin: pmlopes/yoke
static void setJSESSIONID(SockJSHandlerOptions options, YokeRequest request) {
String cookies = request.getHeader("cookie");
if (options.isInsertJSESSIONID()) {
//Preserve existing JSESSIONID, if any
if (cookies != null) {
String[] parts;
if (cookies.contains(";")) {
parts = cookies.split(";");
} else {
parts = new String[] {cookies};
}
for (String part: parts) {
if (part.startsWith("JSESSIONID")) {
cookies = part + "; path=/";
break;
}
}
}
if (cookies == null) {
cookies = "JSESSIONID=dummy; path=/";
}
request.response().putHeader("Set-Cookie", cookies);
}
}
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
final WebClient webClient = WebClient.detect(request.getHeader("user-agent"));
boolean isIE = webClient.getUserAgent() == WebClient.UserAgent.IE;
int majorVersion = webClient.getMajorVersion();
String value;
if ((!isIE) || (majorVersion >= 9) || (setOnOldIE)) {
value = "1; mode=block";
} else {
value = "0";
}
request.response().putHeader("X-XSS-Protection", value);
next.handle(null);
}
}
代码示例来源:origin: pmlopes/yoke
private void handlePreflightRequest(final YokeRequest request)
{
if (isValidOrigin(request.getHeader(ORIGIN)))
{
addCorsResponseHeaders(request.getHeader(ORIGIN),
request.response().setStatusCode(204).setStatusMessage("No Content")).end();
}
else
{
request.response().setStatusCode(403).setStatusMessage("CORS Rejected").end();
}
}
代码示例来源:origin: pmlopes/yoke
final String accept = request.getHeader("accept-encoding");
代码示例来源:origin: pmlopes/yoke
@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
try {
if (log.isTraceEnabled()) log.trace("In Iframe handler");
if (etag != null && etag.equals(request.getHeader("if-none-match"))) {
request.response().setStatusCode(304);
request.response().end();
} else {
long oneYear = 365 * 24 * 60 * 60 * 1000L;
String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYear));
request.response().putHeader("Content-Type", "text/html; charset=UTF-8")
.putHeader("Cache-Control", "public,max-age=31536000")
.putHeader("Expires", expires).putHeader("ETag", etag).end(iframeHTML);
}
} catch (Exception e) {
log.error("Failed to server iframe", e);
}
}
};
代码示例来源:origin: pmlopes/yoke
return request.get(path);
case 4:
return request.getHeader(path);
default:
throw new YokeException(400, "Unknown source " + type);
代码示例来源:origin: pmlopes/yoke
String xHttpMethodOverride = request.getHeader("x-http-setmethod-override");
代码示例来源:origin: pmlopes/yoke
String ct = rc.getHeader("content-type");
if ("application/x-www-form-urlencoded".equalsIgnoreCase(ct)) {
urlEncoded = true;
我尝试在我的 Vertx 项目中实现 Junit5。 只需添加 junit5 就可以正常工作,但是将 vertx-junit5 模块添加到项目后,测试引擎在查找测试时遇到问题 build.gradle
本文整理了Java中com.jetdrone.vertx.yoke.Yoke.vertx()方法的一些代码示例,展示了Yoke.vertx()的具体用法。这些代码示例主要来源于Github/Stack
我试图测试 vertx munity web 客户端提供的响应式(Reactive) web 客户端。 我按照官方指南Quarkus - Getting Started with Reactive .
我一直在尝试将服务迁移到 java 9,尽管我可以编译并运行 fat.jar,但我无法在 Intellij 上运行它,原因是库 vertx 的拆分包问题- hk2 和 vertx.jersey,因为两
我的 Maven 项目中有以下代码: package hello; import org.vertx.java.core.Handler; import org.vertx.java.core.htt
我只是想创建一个 html 页面来获取字符串并在同一页面中再次显示它。我的index.html, Insert title here Create
我遇到了需要纵向扩展的情况,所以我最终得到了一个具有 20 核 和 5GB 的虚拟机。 问题是,当我加载大量数据时,我看不到 CPU 只使用了一个内核。我希望看到 20 个内核 以并行 运行。 我尝试
我已经加入了其中一位 Vertx 爱好者,但是单线程主机可能不适合我,因为在我的服务器中可能同时有 50 个文件下载请求,作为解决方案,我创建了这个类 public abstract T onRun(
我正在VertX中创建cookie,并希望在用户注销后再次将其删除。 AccountController.handleLogin(vertx, router.post("/login")) ... f
我正在尝试在 Vert.x 中创建自己的异步自定义方法,类似于他们的代码: // call the external service WebClient client = WebClient.crea
我正在尝试按照 official vert.x site 上的说明进行操作与通过传递 jvm arg 优雅地启动/停止 vertx verticle 相关 You can also start an
我有 2 个与 Vertx 相关的问题线程模型。 The documentation提及: 默认情况下,Vert.x 实例维护 N 个事件循环线程(其中 N 默认为 core*2)。 对于许多现代应用
我正在生成一个值(使用 uuid java 的 6 个字母数字字母)并检查数据库是否该值已存在。如果该值已存在于数据库中,我会生成新值并再次检查该值是否存在(依此类推)。以同步方式(java),我可以
我希望在应用程序范围变量中设置自定义对象,以便 vertx 可以跨所有微服务请求访问它。我在 Vertx 文档中找不到任何内容。在 Java EE Servlet 中,类似功能的代码是 getServ
我创建了一个 webClient 作为: WebClientOptions options = new WebClientOptions(); WebClient client = WebClient
我正在尝试启动 Vertx.io 服务器的初始测试,但收到以下错误消息: 线程“main”中出现异常 java.lang.NoClassDefFoundError: org/vertx/java/co
我正在尝试使用 dynamoDB 和 lombok 注释运行 vertx 服务器,但无法使其正常工作。我已将 vertx、dynamoDB 和 lombok 的 .jar 文件添加到我的类路径中。一切
操作系统:Linux Vert.x 版本:3.3.3 机器:两台不同的机器同一子网内的不同IP 我想为一个简单的乒乓应用程序启用指标监控,我可以在其中观察两个节点之间发送了多少数据包。 测量的指标应通
我正在开发数据报服务器,它监听特定端口上的消息,我们正在使用 Vertx Java 框架来实现相同的 .如果我在启动垂直时仅在部署选项中指定一个实例,则一切正常。一旦我指定了多个实例,我就会收到套接字
如何将数据追加到文件末尾(或开头)?我尝试使用 list.forEach(str -> { vertx.fileSystem().writeFile(path, Buffer.
我是一名优秀的程序员,十分优秀!