MCPcopy Create free account
hub / github.com/defineYIDA/LWebServer / getSession

Method getSession

src/main/java/cn/lws/server/request/Request.java:141–157  ·  view source on GitHub ↗

如果请求报文中携带JSESSIONID这个Cookie,那么取出对应的session 否则创建一个Session,并在响应报文中添加一个响应头Set-Cookie: JSESSIONID=D5A5C79F3C8E8653BC8B4F0860BFDBCD 所有从请求报文中得到的Cookie,都会在响应报文中返回 服务器只会在客户端第一次请求响应的时候,在响应头上添加Set-Cookie:“JSESSIONID=XXXXXXX”信息, 接下来在同一个会话的第二第三次响应头里,是不会添加Set-Cookie:“JSESSIONID=XXXXXXX”信息的; 即,如果在

()

Source from the content-addressed store, hash-verified

139 * @return HTTPSession
140 */
141 public HTTPSession getSession() {
142 if (session != null) {
143 return session;
144 }
145 for (Cookie cookie : cookies) {
146 if (cookie.getKey().equals("JSESSIONID")) {
147 log.info("servletContext:{}",servletContext);
148 HTTPSession currentSession = servletContext.getSession(cookie.getValue());
149 if (currentSession != null) {
150 this.session = currentSession;
151 return session;
152 }
153 }
154 }
155 session = servletContext.createSession(requestHandler.getResponse());
156 return session;
157 }
158
159 private void parseHeaders(String[] lines) {
160 log.info("解析请求头");

Callers 1

resolveMethod · 0.45

Calls 1

createSessionMethod · 0.80

Tested by

no test coverage detected