Started GetCookies
This commit is contained in:
parent
c6acd8cded
commit
14592db41f
2 changed files with 17 additions and 1 deletions
|
@ -10,6 +10,8 @@ import java.time.ZoneId;
|
|||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -97,4 +99,18 @@ public class IOHelper {
|
|||
exchange.getResponseHeaders().add("Location", url);
|
||||
IOHelper.SendResponse(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange);
|
||||
}
|
||||
|
||||
public static HashMap<String, String> GetCookies(HttpExchange exchange) {
|
||||
if (!exchange.getRequestHeaders().containsKey("Cookie"))
|
||||
return new HashMap<>();
|
||||
HashMap<String, String> map = new HashMap<>(); // TODO
|
||||
for (String cheader : exchange.getRequestHeaders().get("Cookie")) {
|
||||
String[] spl = cheader.split("\\;");
|
||||
for (String s : spl) {
|
||||
String[] kv = s.split("\\=");
|
||||
if (kv.length < 2)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class IndexPage extends Page {
|
|||
|
||||
@Override
|
||||
public void handlePage(HttpExchange exchange) throws IOException {
|
||||
if (exchange.getRequestHeaders().containsKey("Cookie"))
|
||||
if ()
|
||||
System.out.println(exchange.getRequestHeaders().get("Cookie"));
|
||||
IOHelper.SendPage(200, this, exchange);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue