Started GetCookies

This commit is contained in:
Norbi Peti 2016-07-22 15:11:31 +02:00
parent c6acd8cded
commit 14592db41f
2 changed files with 17 additions and 1 deletions

View file

@ -10,6 +10,8 @@ import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -97,4 +99,18 @@ public class IOHelper {
exchange.getResponseHeaders().add("Location", url); exchange.getResponseHeaders().add("Location", url);
IOHelper.SendResponse(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange); 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;
}
}
}
} }

View file

@ -10,7 +10,7 @@ public class IndexPage extends Page {
@Override @Override
public void handlePage(HttpExchange exchange) throws IOException { public void handlePage(HttpExchange exchange) throws IOException {
if (exchange.getRequestHeaders().containsKey("Cookie")) if ()
System.out.println(exchange.getRequestHeaders().get("Cookie")); System.out.println(exchange.getRequestHeaders().get("Cookie"));
IOHelper.SendPage(200, this, exchange); IOHelper.SendPage(200, this, exchange);
} }