Im struggling getting java submitting POST requests over HTTPS
Code used is here
try{ Response res = Jsoup.connect(LOGIN_URL) .data("username", "blah", "password", "blah") .method(Method.POST) .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0") .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") .execute(); System.out.println(res.body()); System.out.println("Code " +res.statusCode()); } catch (Exception e){ System.out.println(e.getMessage()); }
and also this
Document doc = Jsoup.connect(LOGIN_URL) .data("username", "blah") .data("password", "blah") .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0") .header("Content-type", "application/x-www-form-urlencoded") .method(Method.POST) .timeout(3000) .post();
Where LOGIN_URL = https://xxx.com/Login?val=login
When used over HTTP it seems to work, HTTPS it doesnt, But doesnt throw any exceptions
How can I POST over HTTPS
Edit:
seems there is a 302 redirect involved when the server gets a POST over HTTPS (which doesnt happen over http) How can I use jsoup to store the cookie sent with the 302 to the next page ?