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

Commit e2c21c8

Browse files
committed
Updated dependencies
1 parent 41e918d commit e2c21c8

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,16 @@ public final String getDomain(){
211211
* Sets the domain of the cookie.
212212
*
213213
* @param domain what domain to send the cookie to
214+
* @return cookie builder
214215
*
215216
* @see #getDomain()
216217
*
217218
* @since 02.03.00
218219
* @author Ktt Development
219220
*/
220-
public final void setDomain(final String domain){
221+
public final Builder setDomain(final String domain){
221222
this.domain = domain;
223+
return this;
222224
}
223225

224226
/**
@@ -239,14 +241,16 @@ public final String getPath(){
239241
* Sets the path of the cookie.
240242
*
241243
* @param path what path to send the cookie to
244+
* @return cookie builder
242245
*
243246
* @see #getPath()
244247
*
245248
* @since 02.03.00
246249
* @author Ktt Development
247250
*/
248-
public final void setPath(final String path){
251+
public final Builder setPath(final String path){
249252
this.path = path;
253+
return this;
250254
}
251255

252256
/**
@@ -267,14 +271,16 @@ public final String isSameSite(){
267271
* Sets if the cookie should be prevented from being sent cross-site.
268272
*
269273
* @param sameSite if the cookie should be prevented from being sent cross-site
274+
* @return cookie builder
270275
*
271276
* @see #isSameSite()
272277
*
273278
* @since 02.03.00
274279
* @author Ktt Development
275280
*/
276-
public final void setSameSite(final String sameSite){
281+
public final Builder setSameSite(final String sameSite){
277282
this.sameSite = sameSite;
283+
return this;
278284
}
279285

280286
/**
@@ -297,6 +303,7 @@ public final Date getExpires(){
297303
* Sets when the cookie should expire.
298304
*
299305
* @param expires when the cookie should expire
306+
* @return cookie builder
300307
*
301308
* @see #getExpires()
302309
* @see #getMaxAge()
@@ -305,8 +312,9 @@ public final Date getExpires(){
305312
* @since 02.03.00
306313
* @author Ktt Development
307314
*/
308-
public final void setExpires(final Date expires){
315+
public final Builder setExpires(final Date expires){
309316
this.expires = expires;
317+
return this;
310318
}
311319

312320
/**
@@ -329,6 +337,7 @@ public final int getMaxAge(){
329337
* Sets how long the cookie should exist for.
330338
*
331339
* @param maxAge how long the cookie should exist for
340+
* @return cookie builder
332341
*
333342
* @see #getExpires()
334343
* @see #setExpires(Date)
@@ -337,8 +346,9 @@ public final int getMaxAge(){
337346
* @since 02.03.00
338347
* @author Ktt Development
339348
*/
340-
public final void setMaxAge(final int maxAge){
349+
public final Builder setMaxAge(final int maxAge){
341350
this.maxAge = maxAge;
351+
return this;
342352
}
343353

344354
/**
@@ -359,14 +369,16 @@ public final boolean isSecure(){
359369
* Sets if the cookie must be sent over a secure/HTTPS protocol.
360370
*
361371
* @param secure if the cookie must be sent over a secure/HTTPS protocol.
372+
* @return cookie builder
362373
*
363374
* @see #setSecure(boolean)
364375
*
365376
* @since 02.03.00
366377
* @author Ktt Development
367378
*/
368-
public final void setSecure(final boolean secure){
379+
public final Builder setSecure(final boolean secure){
369380
this.secure = secure;
381+
return this;
370382
}
371383

372384
/**
@@ -387,14 +399,16 @@ public final boolean isHttpOnly(){
387399
* Sets if only the server should have access to the cookies.
388400
*
389401
* @param httpOnly if only the server should have access to the cookies
402+
* @return cookie builder
390403
*
391404
* @see #isHttpOnly()
392405
*
393406
* @since 02.03.00
394407
* @author Ktt Development
395408
*/
396-
public final void setHttpOnly(final boolean httpOnly){
409+
public final Builder setHttpOnly(final boolean httpOnly){
397410
this.httpOnly = httpOnly;
411+
return this;
398412
}
399413

400414
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static SimpleHttpExchange create(final HttpExchange exchange){
304304
//
305305

306306
/**
307-
* Returns the client's existing cookies.
307+
* Returns the client's existing cookies as a map of keys and values.
308308
*
309309
* @return client's cookies
310310
*

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @see SimpleHttpExchange
1919
* @since 02.00.00
20-
* @version 02.00.00
20+
* @version 02.03.00
2121
* @author Ktt Development
2222
*/
2323
@SuppressWarnings("SpellCheckingInspection")
@@ -311,7 +311,7 @@ public final HashMap<String, String> getCookies(){
311311

312312
@Override
313313
public synchronized final void setCookie(final SimpleHttpCookie cookie){
314-
getResponseHeaders().add("Set-Cookie",cookie.toString());
314+
getResponseHeaders().add("Set-Cookie",cookie.toCookieHeaderString());
315315
}
316316

317317
//
@@ -322,7 +322,11 @@ public synchronized final HttpSession getHttpSession(){
322322
final HttpSession session;
323323
if((sessionId = cookies.get("__session-id")) == null || !HttpSession.sessions.containsKey(sessionId)){
324324
session = HttpSession.create();
325-
setCookie(new SimpleHttpCookie("__session-id", session.getSessionID(), null, null, null, null, null, false, true));
325+
setCookie(
326+
new SimpleHttpCookie.Builder("__sesion-id",session.getSessionID())
327+
.setHttpOnly(true)
328+
.build()
329+
);
326330
}else{
327331
session = HttpSession.sessions.get(sessionId);
328332
}

0 commit comments

Comments
 (0)