Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit c4b31ae

Browse files
committed
Removed session from exchange
1 parent a4c211f commit c4b31ae

File tree

2 files changed

+1
-35
lines changed

2 files changed

+1
-35
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchange.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,19 +346,6 @@ static SimpleHttpExchange create(final HttpExchange exchange){
346346
*/
347347
public abstract void setCookie(final SimpleHttpCookie cookie);
348348

349-
//
350-
351-
/**
352-
* Returns the http session of the exchange if one exists; if one does not exist it will create one. <b>A new session will only persist if the exchange is sent.</b>
353-
*
354-
* @return http session
355-
*
356-
* @see HttpSession
357-
* @since 02.00.00
358-
* @author Ktt Development
359-
*/
360-
public abstract HttpSession getHttpSession();
361-
362349
//
363350

364351
/**

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeImpl.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -317,32 +317,11 @@ public synchronized final void setCookie(final String key, final String value){
317317
@Override
318318
public synchronized final void setCookie(final SimpleHttpCookie cookie){
319319
final String cstring = cookie.toCookieHeaderString();
320-
if(cstring.startsWith("__session-id="))
321-
throw new IllegalArgumentException("The cookie '__session-id' can not be set because it is reserved by the server");
322320
getResponseHeaders().add("Set-Cookie",cstring);
323321
}
324322

325323
//
326-
327-
@Override
328-
public synchronized final HttpSession getHttpSession(){
329-
final String sessionId;
330-
final HttpSession session;
331-
332-
if((sessionId = cookies.get("__session-id")) == null || !HttpSession.sessions.containsKey(sessionId)){
333-
session = HttpSession.create();
334-
final SimpleHttpCookie cookie =
335-
new SimpleHttpCookie.Builder("__session-id",session.getSessionID())
336-
.setPath("/")
337-
.setHttpOnly(true)
338-
.build();
339-
getResponseHeaders().add("Set-Cookie",cookie.toCookieHeaderString()); // bypass implementation
340-
}else{
341-
session = HttpSession.sessions.get(sessionId);
342-
}
343-
return session;
344-
}
345-
324+
346325
@Override
347326
public final OutputStream getOutputStream(){
348327
return outputStream;

0 commit comments

Comments
 (0)