@@ -57,22 +57,11 @@ public synchronized String assignSessionID(final HttpExchange exchange){
5757 return id ;
5858 }
5959
60- private final Predicate <Headers > hasSetHeader = new Predicate <>() {
61- @ Override
62- public boolean test (final Headers headers ){
63- if (headers .containsKey ("Set-Cookie" ))
64- for (final String value : headers .get ("Set-Cookie" ))
65- if (value .startsWith (cookie + "=" ))
66- return true ;
67- return false ;
68- }
69- };
70-
7160 private String getSetSession (final Headers headers ){
7261 if (headers .containsKey ("Set-Cookie" ))
7362 for (final String value : headers .get ("Set-Cookie" ))
74- if (value .startsWith (cookie + "=" )){
75- return value .substring (value . indexOf ( cookie + '=' ) + 1 ,value .indexOf (";" ));
63+ if (value .startsWith (cookie + "=" ))
64+ return value .substring (cookie . length ( ) + 1 ,value .indexOf (";" ));
7665 return null ;
7766 }
7867
@@ -100,14 +89,12 @@ public final HttpSession getSession(final HttpExchange exchange){
10089 }
10190 }
10291
103- final String cookieSessionId , setCookieSessionId ;
92+ final String setSession = getSetSession (exchange .getResponseHeaders ());
93+ sessionId = setSession != null ? setSession : cookies .get (cookie );
10494
10595 synchronized (this ){
106- if (
107- ((cookieSessionId = cookies .get (cookie )) == null || !sessions .containsKey (sessionId ) ) && (setCookieSessionId = getSetSession (exchange .getResponseHeaders ())) == null
108- ){
96+ if (!sessions .containsKey (sessionId )){
10997 session = new HttpSession () {
110-
11198 private final String sessionID ;
11299 private final long creationTime ;
113100 private long lastAccessTime ;
@@ -168,7 +155,6 @@ public final String toString(){
168155 session = sessions .get (sessionId );
169156 }
170157 }
171- System .out .println (sessions );
172158 return session ;
173159 }
174160
0 commit comments