HttpURLConnection: setRequestMethod(String method) throws ProtocolException
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] argv) throws Exception {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con = (HttpURLConnection) new URL("http://www.google.coom").openConnection();
con.setRequestMethod("HEAD");
System.out.println(con.getResponseCode() == HttpURLConnection.HTTP_OK);
}
}
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()