HttpURLConnection: setInstanceFollowRedirects(boolean followRedirects)
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class Main {
public static void main(String[] argv) throws Exception {
HttpURLConnection.setFollowRedirects(false);
URL url = new URL("http://hostname:80");
URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setInstanceFollowRedirects(false);
conn.connect();
}
}
Home
Java Book
Networking
Java Book
Networking
HttpURLConnection:
- HttpURLConnection
- HttpURLConnection.HTTP_OK
- HttpURLConnection: getContentLength()
- HttpURLConnection: getContentType()
- HttpURLConnection: getDate()
- HttpURLConnection: getExpiration()
- HttpURLConnection: getHeaderFields()
- HttpURLConnection: getInputStream()
- HttpURLConnection: getLastModified()
- HttpURLConnection: getRequestMethod
- HttpURLConnection: getResponseCode()
- HttpURLConnection: getResponseMessage()
- HttpURLConnection: setInstanceFollowRedirects(boolean followRedirects)
- HttpURLConnection: setRequestMethod(String method) throws ProtocolException
- HttpsURLConnection: getDefaultSSLSocketFactory()