I am getting 200 as a response code instead of 3xx when I perform HTTP post request, even though web page gets redirected automatically. I tried this, but dosen't work. My code:
HttpURLConnection con = getMultipartHttpURLConnection(
formParameter.getServerUrl(), boundary);
setRequestHeaders(con);
String urlParameters = getParameter(formParameter.getForm());
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
responseCode = con.getResponseCode();
String header = con.getHeaderField("Location");
Edit:
By some research I find out that if server is configured to redirect to https:// enabled url, then I am getting 3xx as response code, otherwise not. Example given in the link above does the same.