Java HTTP Request getRequest(URL url, int timeout)

Here you can find the source of getRequest(URL url, int timeout)

Description

get Request

License

Open Source License

Declaration

public static HttpURLConnection getRequest(URL url, int timeout) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static final int DEFAULT_HTTP_TIMEOUT = 60000;

    public static HttpURLConnection getRequest(URL url, int timeout) throws IOException {
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");
        conn.setConnectTimeout(timeout);
        conn.setReadTimeout(timeout);/*from w w w . java 2s  .  c  om*/

        return conn;
    }

    public static HttpURLConnection getRequest(URL url) throws IOException {
        return getRequest(url, DEFAULT_HTTP_TIMEOUT);
    }
}

Related

  1. doHttpRequest(String action, URL url, String body, String... args)
  2. getContent(String requestUrl)
  3. getDataFromRequestViaPost(String request, String urlParameters)
  4. getOutputFromUrlConnection(String stringUrl, String requestProperty)
  5. getRequest(String urlString)
  6. getRequestContent(String urlText)
  7. makeUrlRequest(String surl, String data, String method)
  8. request(boolean quiet, String method, URL url, Map body)
  9. request(String httpUrl, Map httpArgMap)