영어 :자바 HttpURLConnection의 더 쿠키
안녕하세요, 저는 현재
가 이미 시도 ... 세션 쿠키를 얻을 후, HttpURLConnection의에 로그인을하고 노력하지있어 그 내 자신에 대한 몇 가지 테스트 페이지에 서버, 그리고 그 완벽하게 작동합니다. "a = 3 & b = 5"를 보내면 "8"이 쿠키가됩니다 (PHP 페이지는 함께 추가됩니다)! 난 그냥 POST에 아무 것도 보내지 않은 것처럼 다른 페이지를 출력 그냥 페이지가 있음을하려고 할 때 는 그러나 :(개선을위한
일반 제안을 환영합니다 :)
내 코드 :!
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("useragent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0");
conn.setRequestProperty("Connection", "keep-alive");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.writeBytes("USER=tennox&PASS=*****");
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String response = new String();
while ((line = in.readLine()) != null) {
response = response + line + "\n";
}
in.close();
System.out.println("headers:");
int i = 0;
String header;
while ((header = conn.getHeaderField(i)) != null) {
String key = conn.getHeaderFieldKey(i);
System.out.println(((key == null) ? "" : key + ": ") + header);
i++;
}
String cookies = conn.getHeaderField("Set-Cookie");
System.out.println("\nCookies: \"" + cookies + "\"");
무형 문화 유산 denke HIER solltest 뒤 죽을 Fragen 안녕히 englisch stellen –
을 GET 기대 덕분에 : P – TeNNoX