Package fi.iki.elonen
Class NanoHTTPD.CookieHandler
- java.lang.Object
-
- fi.iki.elonen.NanoHTTPD.CookieHandler
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.String>
- Enclosing class:
- NanoHTTPD
public class NanoHTTPD.CookieHandler extends java.lang.Object implements java.lang.Iterable<java.lang.String>
Provides rudimentary support for cookies. Doesn't support 'path', 'secure' nor 'httpOnly'. Feel free to improve it and/or add unsupported features.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<java.lang.String,java.lang.String>
cookies
private java.util.ArrayList<NanoHTTPD.Cookie>
queue
-
Constructor Summary
Constructors Constructor Description CookieHandler(java.util.Map<java.lang.String,java.lang.String> httpHeaders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(java.lang.String name)
Set a cookie with an expiration date from a month ago, effectively deleting it on the client side.java.util.Iterator<java.lang.String>
iterator()
java.lang.String
read(java.lang.String name)
Read a cookie from the HTTP Headers.void
set(NanoHTTPD.Cookie cookie)
void
set(java.lang.String name, java.lang.String value, int expires)
Sets a cookie.void
unloadQueue(NanoHTTPD.Response response)
Internally used by the webserver to add all queued cookies into the Response's HTTP Headers.
-
-
-
Field Detail
-
cookies
private final java.util.HashMap<java.lang.String,java.lang.String> cookies
-
queue
private final java.util.ArrayList<NanoHTTPD.Cookie> queue
-
-
Method Detail
-
delete
public void delete(java.lang.String name)
Set a cookie with an expiration date from a month ago, effectively deleting it on the client side.- Parameters:
name
- The cookie name.
-
iterator
public java.util.Iterator<java.lang.String> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.String>
-
read
public java.lang.String read(java.lang.String name)
Read a cookie from the HTTP Headers.- Parameters:
name
- The cookie's name.- Returns:
- The cookie's value if it exists, null otherwise.
-
set
public void set(NanoHTTPD.Cookie cookie)
-
set
public void set(java.lang.String name, java.lang.String value, int expires)
Sets a cookie.- Parameters:
name
- The cookie's name.value
- The cookie's value.expires
- How many days until the cookie expires.
-
unloadQueue
public void unloadQueue(NanoHTTPD.Response response)
Internally used by the webserver to add all queued cookies into the Response's HTTP Headers.- Parameters:
response
- The Response object to which headers the queued cookies will be added.
-
-