I'm having trouble reading what cookies are being sent when making a POST in java.
Here's my code:
public static void main(String[] args) throws MalformedURLException, IOException {
String urlParameters = "votebut=";
String request = "http://www.runelocus.com/toplist/vote-17648.html";
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches(false);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
for (String cookie : cookies) {
System.out.println("Cookies: " + cookie);
}
connection.disconnect();
}
This is what it prints:
Cookies: PHPSESSID=48863f8c3adcbddf0e77e7f1b450fc0e; path=/
This is what I want it to print:
ki_u=68debd85-c1af-f1ff-2e6c-4146755c6e26; ki_t=1354418220596%3B1354418220596%3B1354422379616%3B1%3B36;
Any help please?
Thanks