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

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

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

HttpsURLConnection.setReadTimeout介绍

暂无

代码示例

代码示例来源:origin: jmdhappy/xxpay-master

con.setUseCaches(false);
con.setConnectTimeout(30 * 1000);
con.setReadTimeout(60 * 1000);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()), 1024*1024);

代码示例来源:origin: Javen205/IJPay

conn.setReadTimeout(25000);
conn.setRequestMethod("POST");
conn.setDoOutput(true);

代码示例来源:origin: Javen205/IJPay

conn.setReadTimeout(25000);
conn.setRequestMethod("POST");
conn.setDoOutput(true);

代码示例来源:origin: jmdhappy/xxpay-master

con.setUseCaches(false);
con.setConnectTimeout(10 * 1000);
con.setReadTimeout(5 * 1000);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()), 1024*1024);

代码示例来源:origin: jmdhappy/xxpay-master

con.setUseCaches(false);
con.setConnectTimeout(10 * 1000);
con.setReadTimeout(5 * 1000);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()), 1024*1024);

代码示例来源:origin: wildfly/wildfly

conn.setHostnameVerifier(hostnameVerifier);
conn.setConnectTimeout(CONNECTION_TIMEOUT);
conn.setReadTimeout(CONNECTION_TIMEOUT);
conn.connect();
InputStream inputStream = conn.getInputStream();

代码示例来源:origin: apache/nifi

@Override
  public void run() {
    try {
      final int port = ((HandleHttpRequest) runner.getProcessor()).getPort();
      final HttpsURLConnection connection = (HttpsURLConnection) new URL("https://localhost:"
          + port + "/my/path?query=true&value1=value1&value2=&value3&value4=apple=orange").openConnection();
      connection.setSSLSocketFactory(sslContext.getSocketFactory());
      connection.setDoOutput(false);
      connection.setRequestMethod("GET");
      connection.setRequestProperty("header1", "value1");
      connection.setRequestProperty("header2", "");
      connection.setRequestProperty("header3", "apple=orange");
      connection.setConnectTimeout(3000);
      connection.setReadTimeout(3000);
      StreamUtils.copy(connection.getInputStream(), new NullOutputStream());
    } catch (final Throwable t) {
      t.printStackTrace();
      Assert.fail(t.toString());
    }
  }
});

代码示例来源:origin: chrisk44/Hijacker

HttpsURLConnection connection = (HttpsURLConnection) (new URL(WORDLISTS_LINK).openConnection());
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);

代码示例来源:origin: chrisk44/Hijacker

HttpsURLConnection connection = (HttpsURLConnection) (new URL(RELEASES_LINK).openConnection());
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);

代码示例来源:origin: Azure/azure-iot-sdk-java

/**
 * Sets the read timeout in milliseconds. The read timeout is the number of
 * milliseconds after the server receives a request and before the server
 * sends data back.
 *
 * @param timeout The read timeout.
 */
public void setReadTimeoutMillis(int timeout)
{
  // Codes_SRS_HTTPCONNECTION_25_011: [The function shall set the read timeout to the given value.]
  this.connection.setReadTimeout(timeout);
}

代码示例来源:origin: com.microsoft.azure.iothub-java-client/iothub-java-device-client

/**
 * Sets the read timeout in milliseconds. The read timeout is the number of
 * milliseconds after the server receives a request and before the server
 * sends data back.
 *
 * @param timeout the read timeout.
 */
public void setReadTimeoutMillis(int timeout)
{
  // Codes_SRS_HTTPSCONNECTION_11_023: [The function shall set the read timeout to the given value.]
  this.connection.setReadTimeout(timeout);
}

代码示例来源:origin: Azure/azure-iot-sdk-java

/**
 * Sets the read timeout in milliseconds. The read timeout is the number of
 * milliseconds after the server receives a request and before the server
 * sends data back.
 *
 * @param timeout The read timeout.
 */
public void setReadTimeoutMillis(int timeout)
{
  // Codes_SRS_SERVICE_SDK_JAVA_HTTPCONNECTION_12_011: [The function shall set the read timeout to the given value.]
  this.connection.setReadTimeout(timeout);
}

代码示例来源:origin: sakaiproject/sakai

private static HttpsURLConnection fetchConnection(String apiURL, int timeout, Proxy proxy)
throws MalformedURLException, IOException, ProtocolException {
  HttpsURLConnection connection;
  URL hostURL = new URL(apiURL);
  if (proxy == null) {
    connection = (HttpsURLConnection) hostURL.openConnection();
  } else {
    connection = (HttpsURLConnection) hostURL.openConnection(proxy);
  }
  // This actually turns into a POST since we are writing to the
  // resource body. ( You can see this in Webscarab or some other HTTP
  // interceptor.
  connection.setRequestMethod("GET"); 
  connection.setConnectTimeout(timeout);
  connection.setReadTimeout(timeout);
  connection.setDoOutput(true);
  connection.setDoInput(true);
  return connection;
}

代码示例来源:origin: adjust/android_sdk

@Override
  public void applyConnectionOptions(HttpsURLConnection connection, String clientSdk) {
    connection.setRequestProperty("Client-SDK", clientSdk);
    connection.setConnectTimeout(Constants.ONE_MINUTE);
    connection.setReadTimeout(Constants.ONE_MINUTE);
    if (userAgent != null) {
      connection.setRequestProperty("User-Agent", userAgent);
    }
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private Map<Address, Address> callService() throws IOException, CertificateException {
  URL url = new URL(endpointUrl);
  HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
  httpsConnection.setRequestMethod("GET");
  httpsConnection.setConnectTimeout(connectionTimeoutInMillis);
  httpsConnection.setReadTimeout(connectionTimeoutInMillis);
  httpsConnection.setRequestProperty("Accept-Charset", "UTF-8");
  httpsConnection.connect();
  checkCertificate(httpsConnection);
  checkError(httpsConnection);
  return parseResponse(httpsConnection.getInputStream());
}

代码示例来源:origin: io.takari/jdkget

public static JdkReleases readFromGithub() throws IOException {
 HttpsURLConnection conn = (HttpsURLConnection) new URL(REMOTE_XML).openConnection();
 conn.setAllowUserInteraction(false);
 conn.setDoInput(true);
 conn.setDoOutput(false);
 conn.setUseCaches(true);
 conn.setRequestMethod("GET");
 conn.setConnectTimeout(TIMEOUT_VALUE);
 conn.setReadTimeout(TIMEOUT_VALUE);
 conn.connect();
 return read(conn.getInputStream());
}

代码示例来源:origin: io.fabric8.ipaas.apps/apiman

/**
 * Validates the bearer token with the kubernetes oapi and returns the username
 * if it is a valid token.
 * 
 * @param bearerHeader
 * @return username of the user to whom the token was issued to
 * @throws IOException - when the token is invalid, or oapi cannot be reached.
 */
protected String validateBearerToken(String bearerHeader) throws IOException {
  ObjectMapper mapper = new ObjectMapper();
  HttpsURLConnection con = (HttpsURLConnection) kubernetesOsapiUrl.openConnection();
  con.setRequestProperty("Authorization", bearerHeader);
  con.setConnectTimeout(10000);  
  con.setReadTimeout(10000);
  con.setRequestProperty("Content-Type","application/json");
  if (kubernetesTrustCert) TrustEverythingSSLTrustManager.trustAllSSLCertificates(con);
  con.connect();
  OAuthClientAuthorizationList userList = mapper.readValue(con.getInputStream(), OAuthClientAuthorizationList.class); 
  String userName = userList.getItems().get(0).getMetadata().getName();
  return userName;
}

代码示例来源:origin: io.fabric8.jube.images.fabric8/apiman

/**
 * Validates the bearer token with the kubernetes oapi and returns the username
 * if it is a valid token.
 * 
 * @param bearerHeader
 * @return username of the user to whom the token was issued to
 * @throws IOException - when the token is invalid, or oapi cannot be reached.
 */
protected String validateBearerToken(String bearerHeader) throws IOException {
  ObjectMapper mapper = new ObjectMapper();
  HttpsURLConnection con = (HttpsURLConnection) kubernetesOsapiUrl.openConnection();
  con.setRequestProperty("Authorization", bearerHeader);
  con.setConnectTimeout(10000);  
  con.setReadTimeout(10000);
  con.setRequestProperty("Content-Type","application/json");
  if (kubernetesTrustCert) TrustEverythingSSLTrustManager.trustAllSSLCertificates(con);
  con.connect();
  OAuthClientAuthorizationList userList = mapper.readValue(con.getInputStream(), OAuthClientAuthorizationList.class); 
  String userName = userList.getItems().get(0).getMetadata().getName();
  return userName;
}

代码示例来源:origin: ihaolin/antares

private void prepareRequest() {
  connection.setDoInput(true);
  connection.setDoOutput(true);
  connection.setConnectTimeout(connectTimeout);
  connection.setReadTimeout(readTimeout);
  header("Accept-Charset", acceptCharset);
  header("Connection", connectType);
  if (gzip){
    header("Accept-Encoding", "gzip, deflate");
  }
  if (!Strings.isNullOrEmpty(contentType)){
    header("Content-Type", connectType);
  }
  if (!Strings.isNullOrEmpty(acceptType)){
    header("Accept", acceptType);
  }
  if (!Strings.isNullOrEmpty(body)){
    header("Content-Length", String.valueOf(body.length()));
  }
}

代码示例来源:origin: me.hao0/common

private void prepareRequest() {
  connection.setDoInput(true);
  connection.setDoOutput(true);
  connection.setConnectTimeout(connectTimeout);
  connection.setReadTimeout(readTimeout);
  header("Accept-Charset", acceptCharset);
  header("Connection", connectType);
  if (gzip){
    header("Accept-Encoding", "gzip, deflate");
  }
  if (!Strings.isNullOrEmpty(contentType)){
    header("Content-Type", connectType);
  }
  if (!Strings.isNullOrEmpty(acceptType)){
    header("Accept", acceptType);
  }
  if (!Strings.isNullOrEmpty(body)){
    header("Content-Length", String.valueOf(body.length()));
  }
}

相关文章

HttpsURLConnection类方法