I have the next part of code:
dCon = (HttpURLConnection) new URL(torrentFileDownloadLink).openConnection();
dCon.setRequestProperty("Cookie", "uid=" + cookies.get("uid") + ";pass=" + cookies.get("pass"));
dCon.setRequestMethod("GET");
dCon.setConnectTimeout(30000);
dCon.setDoOutput(true);
But Wireshark shows that request method is "POST". What am I doing wrong or this is just a bug? Btw, getRequestMethod say that method is "GET" but in reality it's POST.
Setting the URLConnection#setDoOutput()
to true
means that you're about to write request data to the request body by URLConnection#getOutputStream()
. This is impossible in combination with GET (which expects the request parameters in the request URL), thus the request method will implicitly be set to POST.
If you don't need to write any data to the request body, then just remove that line. It defaults to false
(and thus GET) anyway.
URLConnection
to fire and handle HTTP requests?If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With