本文整理了Java中org.eclipse.jetty.server.Request.getCookies
方法的一些代码示例,展示了Request.getCookies
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getCookies
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Request
类名称:Request
方法名:getCookies
暂无
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory cookie(Environment env, String name) {
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equalsIgnoreCase(name)) {
return ArrayMemory.ofBean(env, cookie).toConstant();
}
}
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Memory cookies(Environment env) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
ArrayMemory result = ArrayMemory.createHashed(cookies.length);
for (Cookie cookie : cookies) {
if (result.containsKey(cookie.getName())) {
ReferenceMemory list = result.getByScalar(cookie.getName());
if (list.isArray()) {
list.refOfPush().assign(ArrayMemory.ofBean(env, cookie));
} else {
result.putAsKeyString(cookie.getName(), ArrayMemory.of(list.toValue(), ArrayMemory.ofBean(env, cookie)));
}
} else {
result.putAsKeyString(cookie.getName(), ArrayMemory.ofBean(env, cookie));
}
}
return result;
} else {
return new ArrayMemory().toConstant();
}
}
代码示例来源:origin: i2p/i2p.i2p
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
_writer.write(" -");
代码示例来源:origin: org.keycloak/spring-boot-container-bundle
@Override
public Cookie getCookie(String cookieName) {
if (request.getCookies() == null) return null;
javax.servlet.http.Cookie cookie = null;
for (javax.servlet.http.Cookie c : request.getCookies()) {
if (c.getName().equals(cookieName)) {
cookie = c;
break;
}
}
if (cookie == null) return null;
return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath());
}
代码示例来源:origin: org.keycloak/keycloak-jetty-adapter-spi
@Override
public Cookie getCookie(String cookieName) {
if (request.getCookies() == null) return null;
javax.servlet.http.Cookie cookie = null;
for (javax.servlet.http.Cookie c : request.getCookies()) {
if (c.getName().equals(cookieName)) {
cookie = c;
break;
}
}
if (cookie == null) return null;
return new Cookie(cookie.getName(), cookie.getValue(), cookie.getVersion(), cookie.getDomain(), cookie.getPath());
}
代码示例来源:origin: stackoverflow.com
Client client = new Client(Protocol.HTTP);
Request req = new Request();
req.setMethod(Method.POST); // can be Method.GET
req.setResourceRef(new Reference(/* SERVER URL */+ "/jsonservice"));
req.getCookies().add(GAuth.getCookie());
/* Build your JSONObject */
req.setEntity(/* JSONObject */.toString(), MediaType.APPLICATION_JSON);
req.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.APPLICATION_JSON));
Response resp = client.handle(req);
if (resp.getStatus() == Status.SUCCESS_OK)
{
// resp.getEntity().getText() -> The JSON string returned by GAE
JSONObject jo=new JSONObject(resp.getEntity().getText());
/* Use your JSON object */
}
代码示例来源:origin: mkalus/segrada
IUser user = null;
for (Cookie c : ((Request) servletRequest).getCookies()) {
if (c.getName().equals(LoginController.REMEMBER_ME_COOKIE_NAME)) {
RememberMeRepository rememberMeRepository = injector.getInstance(RememberMeRepository.class);
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: Nextdoor/bender
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: jenkinsci/winstone
Cookie[] cookies = request.getCookies();
if (cookies == null || cookies.length == 0)
buf.append(" -");
代码示例来源:origin: com.nesscomputing.components/ness-tracking
cookies = request.getCookies();
代码示例来源:origin: com.nesscomputing.components/ness-httpserver
@Test
public void testLog4jLoggerWorks()
{
Request req = createNiceMock(Request.class);
Response resp = createNiceMock(Response.class);
expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
Cookie[] cookies = {new Cookie("trumpet-JSON-api-AUTHORIZATION", "omgwtfbbq")};
expect(req.getCookies()).andReturn(cookies).anyTimes();
expect(req.getMethod()).andReturn("GET").anyTimes();
expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
expect(req.getQueryString()).andReturn("?bar").anyTimes();
expect(req.getContentLength()).andReturn(42).anyTimes();
expect(req.getTimeStamp()).andReturn(10000L).anyTimes();
expect(resp.getStatus()).andReturn(201).anyTimes();
replayAll();
final Config config = Config.getFixedConfig("ness.httpserver.request-log.log4j.enabled", "true");
final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(), new Log4jRequestLogModule(config));
inj.injectMembers(this);
Assert.assertNotNull(log);
log.log(req, resp);
verifyAll();
}
代码示例来源:origin: com.nesscomputing.components/ness-httpserver
@Test
public void testNullCookies() {
final Config config = Config.getFixedConfig("ness.httpserver.request-log.file.enabled", "true",
"ness.httpserver.request-log.file.fields", "remoteAddr,cookie:trumpet-json-api-authorization,method,requestUri,query,responseCode,responseHeader:Content-Length");
final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(), new FileRequestLogModule(config));
inj.injectMembers(this);
Assert.assertNotNull(fileRequestLog);
StringWriter buffer = new StringWriter();
fileRequestLog.setWriter(new PrintWriter(buffer));
Request req = createMock(Request.class);
Response resp = createMock(Response.class);
expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
expect(req.getCookies()).andReturn(null).anyTimes();
expect(req.getMethod()).andReturn("GET").anyTimes();
expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
expect(req.getRequestURI()).andReturn("foo").anyTimes();
expect(req.getQueryString()).andReturn("?bar").anyTimes();
expect(resp.getStatus()).andReturn(201).anyTimes();
expect(resp.getHeader("Content-Length")).andReturn("42").anyTimes();
replayAll();
fileRequestLog.log(req, resp);
assertEquals("1.2.3.4\t\tGET\tfoo\t?bar\t201\t42\n", buffer.getBuffer().toString());
verifyAll();
}
代码示例来源:origin: com.nesscomputing.components/ness-httpserver
@Test
public void testRequestLogging()
{
final Config config = Config.getFixedConfig("ness.httpserver.request-log.file.enabled", "true",
"ness.httpserver.request-log.file.fields", "remoteAddr,cookie:trumpet-json-api-authorization,cookie:not-here,method,requestUri,query,responseCode,responseHeader:Content-Length,elapsedTime");
final Injector inj = Guice.createInjector(Stage.PRODUCTION, disableStuff(), new LogFieldsModule(), new FileRequestLogModule(config));
inj.injectMembers(this);
Assert.assertNotNull(fileRequestLog);
StringWriter buffer = new StringWriter();
fileRequestLog.setWriter(new PrintWriter(buffer));
Request req = createMock(Request.class);
Response resp = createMock(Response.class);
expect(req.getRemoteAddr()).andReturn("1.2.3.4").anyTimes();
Cookie[] cookies = {new Cookie("trumpet-JSON-api-AUTHORIZATION", "omgwtfbbq")};
expect(req.getCookies()).andReturn(cookies).anyTimes();
expect(req.getMethod()).andReturn("GET").anyTimes();
expect(req.getRequestURI()).andReturn("foo").anyTimes();
expect(req.getRequestURL()).andReturn(new StringBuffer("foo")).anyTimes();
expect(req.getQueryString()).andReturn("?bar").anyTimes();
expect(req.getTimeStamp()).andReturn(10000L).anyTimes();
expect(resp.getStatus()).andReturn(201).anyTimes();
expect(resp.getHeader("Content-Length")).andReturn("42").anyTimes();
replayAll();
DateTimeUtils.setCurrentMillisFixed(11500);
fileRequestLog.log(req, resp);
assertEquals("1.2.3.4\tomgwtfbbq\t\tGET\tfoo\t?bar\t201\t42\t1500\n", buffer.getBuffer().toString());
verifyAll();
}
内容来源于网络,如有侵权,请联系作者删除!