执行HTTP GET请求。

@param url    请求地址
@param params 请求参数
@return 响应字符串
@throws IOException
480173
public static String doGet(String url, Map<String, String> header, Map<String, String> params) throws IOException {
    return doRequestWithUrl(url, METHOD_GET, header, params, DEFAULT_CHARSET);
  }
905592
protected static InputStream downloadMaterial(String url, String params) throws IOException {
		URL _url = new URL(url);
		HttpURLConnection conn = (HttpURLConnection) _url.openConnection();
		// 连接超时
		conn.setConnectTimeout(25000);
		// 读取超时 --服务器响应比较慢，增大时间
		conn.setReadTimeout(25000);
		conn.setRequestMethod("POST");
		conn.setRequestProperty("Content-Type", "Keep-Alive");
		conn.setRequestProperty("User-Agent", DEFAULT_USER_AGENT);
		conn.setDoOutput(true);
		conn.setDoInput(true);
		conn.connect();
		if (StrKit.notBlank(params)) {
			OutputStream out = conn.getOutputStream();
			out.write(params.getBytes(Charsets.UTF_8));
			out.flush();
			IOUtils.closeQuietly(out);
		}
		return conn.getInputStream();
	}
1053910
public String get(String endpoint, String params) throws IOException {
        return this.get(endpoint, params, null);
    }
1361326
public static String post(String url, Map<String, String> customHeaders, Map<String, String> params) throws IOException, HTTPException {
        LOGGER.log(Level.INFO, "Sending POST request to the url {0}", url);

        HttpPost httpPost = new HttpPost(url);

        populateHeaders(httpPost, customHeaders);

        if (params != null && params.size() > 0) {
            List<NameValuePair> nameValuePairs = new ArrayList<>();
            for (Map.Entry<String, String> param : params.entrySet()) {
                nameValuePairs.add(new BasicNameValuePair(param.getKey(), param.getValue()));
            }
            httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        }

        HttpClient httpClient = HttpClientBuilder.create().build();

        HttpResponse httpResponse = httpClient.execute(httpPost);

        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (isErrorStatus(statusCode)) {
            String jsonErrorResponse = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
            throw new HTTPException(statusCode, httpResponse.getStatusLine().getReasonPhrase(), jsonErrorResponse);
        }

        return EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
    }
80338
public static String post(String url,
                              Map<String, String> header,
                              Map<String, String> params) throws IOException {

        HttpURLConnection httpUrlConn = httpUrlConn(url);
        httpUrlConn.setDoOutput(true);
        httpUrlConn.setRequestMethod(Constant.RequestMethodPost);
        // header
        if (header != null) {
            header(header, httpUrlConn);
        }

        httpUrlConn.connect();

        // out
        if (params != null) {
            PrintWriter pw = new PrintWriter(httpUrlConn.getOutputStream());
            String param = Utils.getUrlParamsByMap(params);
            pw.print(param);
            pw.flush();
            pw.close();
        }

        return readIO(httpUrlConn);
    }
1111879
public static String doPost(String url, Map<String, String> params, String charset, int connectTimeout, int readTimeout) throws IOException {
        return doPost(url, params, charset, connectTimeout, readTimeout, null);
    }
334730
private static HttpURLConnection open(URL url) throws IOException {
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setReadTimeout(TIMEOUT);
        c.setConnectTimeout(TIMEOUT);
        return c;
    }
20705
public static byte[] getBytes(URL url) throws IOException {
        final String path = url.getPath();
        final File file = new File(path);
        if (file.exists()) {
            return getFileBytes(file);
        }

        return null;
    }
1172540
public String doGet(String url) throws IOException {
        HttpGet httpGet = new HttpGet(getWsapiUrl() + url);
        return doRequest(httpGet);
    }
450186
public Object getRequest(String restUrl, Map<String, String> params) throws IOException, WebServiceException {
		HttpURLConnection conn = null;
		try {
			// Make the URL
			urlString = new StringBuilder(this.host).append(restUrl);
			urlString.append(this.makeParamsString(params, true));
		    LOGGER.debug("Doing HTTP request: GET [{}]", urlString.toString());
			// Connection configuration
//            Proxy proxy = DEBUG_HTTP ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8008)) : Proxy.NO_PROXY;			
            URL url = new URL(urlString.toString());
			conn = (HttpURLConnection) url.openConnection();
			conn.setRequestMethod(HttpMethod.GET.name());
			conn.setRequestProperty("Connection", "Keep-Alive");

			// Gets the response
			return this.readResponse(restUrl, conn);
        } catch (WebServiceException e) {
            LOGGER.debug("WebServiceException catched. Request error", e);
            throw e;
		} catch (IOException e) {
            LOGGER.debug("IOException catched. Request error", e);
			throw e;
		} catch (Exception e) {
            LOGGER.debug("Exception catched, throwing a new IOException. Request error", e);
            throw new IOException(e.getLocalizedMessage());
		} finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
	}
975467
public JSONObject makeHttpRequest(String url) throws IOException {

        InputStream is = null;
        JSONObject jObj = null;
        String json = null;
        // Making HTTP request
        try {

            is = new URL(url).openStream();


        } catch (Exception ex) {
            Log.d("Networking", ex.getLocalizedMessage());
            throw new IOException("Error connecting");
        }

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            json = sb.toString();
            reader.close();

        } catch (Exception e) {
            Log.e("Buffer Error", "Error converting result " + e.toString());
        } finally{
            try {
                is.close();
            }catch (Exception ex){}
        }

        // try parse the string to a JSON object
        try {
            jObj = new JSONObject(json);
        } catch (JSONException e) {
            Log.e("JSON Parser", "Error parsing data " + e.toString());
        }

        // return JSON String
        return jObj;

    }
366237
public CloseableHttpResponse get(String url, Map<String, String> reqHeaders) throws IOException {
        CloseableHttpClient req = getClient();
        CloseableHttpResponse resp = null;
        HttpGet get = new HttpGet(url);
        addHeaders(get, reqHeaders);
        resp = req.execute(get);
        return resp;
    }
465706
public static Get get(String url, int connectTimeout, int readTimeout) {

        try {
            return new Get(url, connectTimeout, readTimeout);
        } catch (Exception e) {
            throw new HttpException("Failed URL: " + url, e);
        }
    }
1105365
public Response get(String path, Map<String, String> params) throws IOException, RESTException {
        return get(path, params, null);
    }
92265
public static String doGet(String url, Map<String, String> params,
                               String charset) throws IOException {
        HttpURLConnection conn = null;
        String rsp = null;

        try {
            String ctype = "application/x-www-form-urlencoded;charset=" + charset;
            String query = buildQuery(params, charset);
            try {
                conn = getConnection(buildGetUrl(url, query), METHOD_GET, ctype);
            } catch (IOException e) {
                Map<String, String> map = getParamsFromUrl(url);
                AlipayLogger.logCommError(e, url, map.get("app_key"), map.get("method"), params);
                throw e;
            }

            try {
                rsp = getResponseAsString(conn);
            } catch (IOException e) {
                Map<String, String> map = getParamsFromUrl(url);
                AlipayLogger.logCommError(e, conn, map.get("app_key"), map.get("method"), params);
                throw e;
            }

        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        return rsp;
    }
928856
@SuppressWarnings("UnusedReturnValue")
    public static String webread(URL url) throws IOException {
        StringBuilder result = new StringBuilder();
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }
        rd.close();
        return result.toString();
    }
135775
private function apiGet($url, $params)
    {
        $url = $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params);

        try {
            $response = $this->httpClient->request('GET', $url, [
                'headers' => [
                    'user-key' => $this->igdbKey,
                    'Accept' => 'application/json'
                ]
            ]);
        } catch (RequestException $exception) {
            if ($response = $exception->getResponse()) {
                throw new \Exception($exception);
            }
            throw new \Exception($exception);
        } catch (Exception $exception) {
            throw new \Exception($exception);
        }

        return $response->getBody();
    }