javax.net.ssl.HttpsURLConnection.setInstanceFollowRedirects()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中javax.net.ssl.HttpsURLConnection.setInstanceFollowRedirects()方法的一些代码示例,展示了HttpsURLConnection.setInstanceFollowRedirects()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpsURLConnection.setInstanceFollowRedirects()方法的具体详情如下:
包路径:javax.net.ssl.HttpsURLConnection
类名称:HttpsURLConnection
方法名:setInstanceFollowRedirects

HttpsURLConnection.setInstanceFollowRedirects介绍

暂无

代码示例

代码示例来源:origin: lkuza2/java-speech-api

httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();

代码示例来源:origin: wso2-attic/esb-connectors

HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
httpsConnection.setInstanceFollowRedirects(false);
httpsConnection.setRequestMethod(httpMethod);

代码示例来源:origin: TheHolyWaffle/League-of-Legends-XMPP-Chat-Library

private String request(String URL) throws IOException {
  for (final RateLimiter limiter : rateLimiters) {
    limiter.acquire();
  }
  for (final RateLimiter limiter : rateLimiters) {
    limiter.enter();
  }
  final String requestURL = URL;
  final URL url = new URL(requestURL);
  final HttpsURLConnection connection = (HttpsURLConnection) url
      .openConnection();
  connection.setRequestMethod("GET");
  connection.setInstanceFollowRedirects(false);
  if (connection.getResponseCode() != 200) {
    throw new IOException("Response code is "
        + connection.getResponseCode() + " instead of 200.");
  }
  final InputStream is = connection.getInputStream();
  final BufferedReader rd = new BufferedReader(new InputStreamReader(is,
      "utf-8"));
  String line;
  final StringBuffer response = new StringBuffer();
  while ((line = rd.readLine()) != null) {
    response.append(line);
  }
  connection.disconnect();
  return response.toString();
}

代码示例来源:origin: org.wso2.esb.integration/integration-base

HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
httpsConnection.setInstanceFollowRedirects(false);
httpsConnection.setRequestMethod(httpMethod);

代码示例来源:origin: tmobile/pacbot

con = (HttpsURLConnection) serviceUrl.openConnection();
con.setDoOutput(true);
con.setInstanceFollowRedirects(false);
con.setRequestMethod("POST");
con.setRequestProperty(CONTENT_TYPE, "application/x-www-form-urlencoded");

代码示例来源:origin: tmobile/pacbot

con = (HttpsURLConnection) serviceUrl.openConnection();
con.setDoOutput(true);
con.setInstanceFollowRedirects(false);
con.setRequestMethod("POST");
con.setRequestProperty(CONTENT_TYPE, "application/x-www-form-urlencoded");

代码示例来源:origin: tmobile/pacbot

con = (HttpsURLConnection) url.openConnection();
con.setDoOutput(true);
con.setInstanceFollowRedirects(false);
con.setRequestMethod("POST");
con.setRequestProperty(CONTENT_TYPE, "application/json");

代码示例来源:origin: org.wso2.esb.integration/integration-base

HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
httpsConnection.setInstanceFollowRedirects(false);
httpsConnection.setRequestMethod(httpMethod);

代码示例来源:origin: wso2-attic/esb-connectors

HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
httpsConnection.setInstanceFollowRedirects(false);
httpsConnection.setRequestMethod(httpMethod);

代码示例来源:origin: chenerzhu/proxy-pool

httpsURLConnection.setConnectTimeout(2 * 1000);
httpsURLConnection.setReadTimeout(3 * 1000);
httpsURLConnection.setInstanceFollowRedirects(false);
BufferedReader br = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()));
String s = null;

代码示例来源:origin: lkuza2/java-speech-api

httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);

代码示例来源:origin: KickVN/SaliensAuto

public static String githubApi(String text) {
    try {
      trustAllHosts();
      URL url = new URL("https://api.github.com/repos/KickVN/SaliensAuto/"+text);
      HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
      conn.setConnectTimeout(15000);
      conn.setReadTimeout(30000);
      conn.setDoOutput(true);
      conn.setInstanceFollowRedirects(false);
      conn.setRequestMethod("GET");
      conn.setRequestProperty("Accept", "application/vnd.github.v3+json");
      conn.setRequestProperty("User-Agent","SaliensAuto (https://github.com/KickVN/SaliensAuto)");
//            conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36");
      conn.setUseCaches(false);
      BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF8"));
      if (conn.getResponseCode() != 200) return null;
      StringBuilder result = new StringBuilder();
      String line;
      while ((line = in.readLine()) != null) {
        result.append(line);
      }
      conn.disconnect();
      in.close();
      return result.toString();
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }

代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play

cssl.setInstanceFollowRedirects(this.followRedirects);
} else {
  HttpURLConnection c = (HttpURLConnection) connection;

代码示例来源:origin: Tencent-YouTu/android_sdk

connection.setDoInput(true);
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type", "text/json");
connection.connect();

代码示例来源:origin: Tencent-YouTu/android_sdk

connection.setDoInput(true);
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type", "text/json");
connection.connect();

代码示例来源:origin: iyzico/iyzipay-java

private String send(String url, HttpMethod httpMethod, InputStream content, Map<String, String> headers) {
  URLConnection raw;
  HttpsURLConnection conn = null;
  try {
    raw = new URL(url).openConnection();
    conn = HttpsURLConnection.class.cast(raw);
    conn.setSSLSocketFactory(socketFactory);
    conn.setRequestMethod(httpMethod.name());
    conn.setConnectTimeout(TIMEOUT);
    conn.setReadTimeout(TIMEOUT);
    conn.setUseCaches(false);
    conn.setInstanceFollowRedirects(false);
    prepareHeaders(headers, conn);
    if (content != null) {
      prepareRequestBody(httpMethod, content, conn);
    }
    return new String(body(conn), Charset.forName("UTF-8"));
  } catch (Exception e) {
    throw new HttpClientException(e.getMessage(), e);
  } finally {
    if (conn != null) {
      conn.disconnect();
    }
  }
}

代码示例来源:origin: lkuza2/java-speech-api

/**
 * @param sampleRate
 * @param url
 * @return
 * @throws IOException
 */
private HttpsURLConnection getHttpsURLConnection(int sampleRate, URL url) throws IOException {
  URLConnection urlConn = url.openConnection();
  if (!(urlConn instanceof HttpsURLConnection)) {
    throw new IOException ("URL is not an Https URL");
  }
  HttpsURLConnection httpConn = (HttpsURLConnection)urlConn;
  httpConn.setAllowUserInteraction(false);
  httpConn.setInstanceFollowRedirects(true);
  httpConn.setRequestMethod("POST");
  httpConn.setDoOutput(true);
  httpConn.setChunkedStreamingMode(0);
  httpConn.setRequestProperty("Transfer-Encoding", "chunked");
  httpConn.setRequestProperty("Content-Type", "audio/x-flac; rate=" + sampleRate);
  // also worked with ("Content-Type", "audio/amr; rate=8000");
  httpConn.connect();
  return httpConn;
}

代码示例来源:origin: andforce/iBeebo

uRLConnection.setConnectTimeout(CONNECT_TIMEOUT);
uRLConnection.setReadTimeout(READ_TIMEOUT);
uRLConnection.setInstanceFollowRedirects(false);
uRLConnection.setRequestProperty("Connection", "Keep-Alive");
uRLConnection.setRequestProperty("Charset", "UTF-8");

代码示例来源:origin: com.dslplatform/dsl-clc

final URL latest = new URL("https://github.com/ngs-doo/revenj/releases/latest");
final HttpsURLConnection conn = (HttpsURLConnection) latest.openConnection();
conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false);
conn.connect();

代码示例来源:origin: KickVN/SaliensAuto

conn.setReadTimeout(30000);
conn.setDoOutput(true);
conn.setInstanceFollowRedirects(false);
conn.setRequestMethod(post?"POST":"GET");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");

相关文章

HttpsURLConnection类方法