本文整理了Java中org.jooby.Request.header
方法的一些代码示例,展示了Request.header
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.header
方法的具体详情如下:
包路径:org.jooby.Request
类名称:Request
方法名:header
[英]Get a HTTP header.
[中]获取HTTP头。
代码示例来源:origin: jooby-project/jooby
@Override
public Mutant header(final String name) {
return req.header(name);
}
代码示例来源:origin: jooby-project/jooby
@Override
public Mutant header(final String name, final String... xss) {
return req.header(name, xss);
}
代码示例来源:origin: jooby-project/jooby
/**
* @return True if the <code>X-Requested-With</code> header is set to <code>XMLHttpRequest</code>.
*/
default boolean xhr() {
return header("X-Requested-With")
.toOptional(String.class)
.map("XMLHttpRequest"::equalsIgnoreCase)
.orElse(Boolean.FALSE);
}
代码示例来源:origin: jooby-project/jooby
@Override
public String getRequestHeader(final String name) {
return req.header(name).value(null);
}
代码示例来源:origin: jooby-project/jooby
@Override public String getRequestHeader(String name) {
return req.header(name).toOptional().orElse(null);
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
Optional<String> origin = req.header("Origin").toOptional();
Cors cors = this.cors.orElseGet(() -> req.require(Cors.class));
if (cors.enabled() && origin.isPresent()) {
cors(cors, req, rsp, origin.get());
}
chain.next(req, rsp);
}
代码示例来源:origin: jooby-project/jooby
if (extended) {
sb.append(SP);
sb.append(Q).append(req.header(REFERER).value(DASH)).append(Q).append(SP);
sb.append(Q).append(req.header(USER_AGENT).value(DASH)).append(Q);
代码示例来源:origin: jooby-project/jooby
protected void handshake(final Request req, final Runnable handler) throws Exception {
this.injector = req.require(Injector.class);
this.renderers = ImmutableList.copyOf(injector.getInstance(Renderer.KEY));
this.produces = req.route().produces();
this.locals = req.attributes();
this.lastEventId = req.header("Last-Event-ID");
this.locale = req.locale();
handshake(handler);
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp, final Route.Chain chain)
throws Throwable {
/**
* Get or generate a token
*/
Session session = req.session();
String token = session.get(name).toOptional().orElseGet(() -> {
String newToken = generator.apply(req);
session.set(name, newToken);
return newToken;
});
req.set(name, token);
if (requireToken.test(req)) {
String candidate = req.header(name).toOptional()
.orElseGet(() -> req.param(name).toOptional().orElse(null));
if (!token.equals(candidate)) {
throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
}
}
chain.next(req, rsp);
}
}
代码示例来源:origin: jooby-project/jooby
boolean ifnm = req.header("If-None-Match").toOptional()
.map(etag::equals)
.orElse(false);
long lastModified = asset.lastModified();
if (lastModified > 0) {
boolean ifm = req.header("If-Modified-Since").toOptional(Long.class)
.map(ifModified -> lastModified / 1000 <= ifModified / 1000)
.orElse(false);
代码示例来源:origin: jooby-project/jooby
boolean allowMethod = req.header(AC_REQUEST_METHOD).toOptional()
.map(cors::allowMethod)
.orElse(false);
List<String> headers = req.header(AC_REQUEST_HEADERS).toOptional().map(header ->
Splitter.on(',').trimResults().omitEmptyStrings().splitToList(header)
).orElse(Collections.emptyList());
代码示例来源:origin: org.jooby/jooby
@Override
public Mutant header(final String name) {
return req.header(name);
}
代码示例来源:origin: org.jooby/jooby
@Override
public Mutant header(final String name, final String... xss) {
return req.header(name, xss);
}
代码示例来源:origin: org.jooby/jooby
/**
* @return True if the <code>X-Requested-With</code> header is set to <code>XMLHttpRequest</code>.
*/
default boolean xhr() {
return header("X-Requested-With")
.toOptional(String.class)
.map("XMLHttpRequest"::equalsIgnoreCase)
.orElse(Boolean.FALSE);
}
代码示例来源:origin: org.jooby/jooby-pac4j
@Override
public String getRequestHeader(final String name) {
return req.header(name).value(null);
}
代码示例来源:origin: org.jooby/jooby
@Override
public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
Optional<String> origin = req.header("Origin").toOptional();
Cors cors = this.cors.orElseGet(() -> req.require(Cors.class));
if (cors.enabled() && origin.isPresent()) {
cors(cors, req, rsp, origin.get());
}
chain.next(req, rsp);
}
代码示例来源:origin: org.jooby/jooby
if (extended) {
sb.append(SP);
sb.append(Q).append(req.header(REFERER).value(DASH)).append(Q).append(SP);
sb.append(Q).append(req.header(USER_AGENT).value(DASH)).append(Q);
代码示例来源:origin: org.jooby/jooby
protected void handshake(final Request req, final Runnable handler) throws Exception {
this.injector = req.require(Injector.class);
this.renderers = ImmutableList.copyOf(injector.getInstance(Renderer.KEY));
this.produces = req.route().produces();
this.locals = req.attributes();
this.lastEventId = req.header("Last-Event-ID");
this.locale = req.locale();
handshake(handler);
}
代码示例来源:origin: org.jooby/jooby
@Override
public void handle(final Request req, final Response rsp, final Route.Chain chain)
throws Throwable {
/**
* Get or generate a token
*/
Session session = req.session();
String token = session.get(name).toOptional().orElseGet(() -> {
String newToken = generator.apply(req);
session.set(name, newToken);
return newToken;
});
req.set(name, token);
if (requireToken.test(req)) {
String candidate = req.header(name).toOptional()
.orElseGet(() -> req.param(name).toOptional().orElse(null));
if (!token.equals(candidate)) {
throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
}
}
chain.next(req, rsp);
}
}
代码示例来源:origin: org.jooby/jooby
boolean ifnm = req.header("If-None-Match").toOptional()
.map(etag::equals)
.orElse(false);
long lastModified = asset.lastModified();
if (lastModified > 0) {
boolean ifm = req.header("If-Modified-Since").toOptional(Long.class)
.map(ifModified -> lastModified / 1000 <= ifModified / 1000)
.orElse(false);
内容来源于网络,如有侵权,请联系作者删除!