I do both the browser and third-party sites request:
(from https://www.hurl.it/ )
GET https://********* HEADERS Accept: */* Accept-Encoding: gzip, deflate User-Agent: runscope/0.1 I get the answer: 302 Moved Temporarily . All right.
Now I make the same request for Java (for the purity of the experiment I copied all the headers):
HttpURLConnection connection = (HttpURLConnection) new URL("https://*****").openConnection(); connection.setRequestProperty("Accept"," */*"); connection.setRequestProperty("Accept-Encoding", "gzip, deflate"); connection.setRequestProperty("User-Agent", "runscope/0.1"); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder page = new StringBuilder(); String read; while ((read = in.readLine()) != null) page.append(read); System.out.println(connection.getResponseCode()); I get the answer 200 . Checked on other requests. Plus, on this request, the site should send set-cookies, it does not send them to Java. What's wrong?
UPD. Just make a request manually through a socket. Received 302 , as it should be. What is wrong with this HttpURLConnection ? Can someone tell me how to see what he actually sends to the server?