本文整理了Java中java.net.HttpURLConnection.getConnectTimeout()
方法的一些代码示例,展示了HttpURLConnection.getConnectTimeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpURLConnection.getConnectTimeout()
方法的具体详情如下:
包路径:java.net.HttpURLConnection
类名称:HttpURLConnection
方法名:getConnectTimeout
暂无
代码示例来源:origin: square/okhttp
@Override public int getConnectTimeout() {
return delegate.getConnectTimeout();
}
代码示例来源:origin: prestodb/presto
@Override public int getConnectTimeout() {
return delegate.getConnectTimeout();
}
代码示例来源:origin: jeremylong/DependencyCheck
checkForCommonExceptionTypes(ex);
final String msg = format("Error saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n",
url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding);
throw new DownloadFailedException(msg, ex);
} catch (Exception ex) {
final String msg = format("Unexpected exception saving '%s' to file '%s'%nConnection Timeout: %d%nEncoding: %s%n",
url.toString(), outputPath.getAbsolutePath(), conn.getConnectTimeout(), encoding);
throw new DownloadFailedException(msg, ex);
} finally {
代码示例来源:origin: jersey/jersey
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
代码示例来源:origin: jersey/jersey
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
代码示例来源:origin: org.glassfish.jersey.core/jersey-client
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
代码示例来源:origin: pwittchen/ReactiveNetwork
@Test public void shouldCreateHttpUrlConnection() throws IOException {
// given
final String parsedDefaultHost = "clients3.google.com";
// when
HttpURLConnection connection = strategy.createHttpUrlConnection(getHost(), PORT, TIMEOUT_IN_MS);
// then
assertThat(connection).isNotNull();
assertThat(connection.getURL().getHost()).isEqualTo(parsedDefaultHost);
assertThat(connection.getURL().getPort()).isEqualTo(PORT);
assertThat(connection.getConnectTimeout()).isEqualTo(TIMEOUT_IN_MS);
assertThat(connection.getReadTimeout()).isEqualTo(TIMEOUT_IN_MS);
assertThat(connection.getInstanceFollowRedirects()).isFalse();
assertThat(connection.getUseCaches()).isFalse();
}
代码示例来源:origin: javalite/activejdbc
/**
* Returns input stream to read server response from.
*
* @return input stream to read server response from.
*/
public InputStream getInputStream() {
try {
return connection.getInputStream();
}catch(SocketTimeoutException e){
throw new HttpException("Failed URL: " + url +
", waited for: " + connection.getConnectTimeout() + " milliseconds", e);
}catch (Exception e) {
throw new HttpException("Failed URL: " + url, e);
}
}
代码示例来源:origin: EvoSuite/evosuite
@Override
public int getConnectTimeout() {
return super.getConnectTimeout();
}
代码示例来源:origin: apiman/apiman
@Override public int getConnectTimeout() {
return delegate.getConnectTimeout();
}
代码示例来源:origin: org.codelibs/jcifs
@Override
public int getConnectTimeout () {
return this.connection.getConnectTimeout();
}
代码示例来源:origin: com.squareup.okhttp/okhttp-urlconnection
@Override public int getConnectTimeout() {
return delegate.getConnectTimeout();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp-urlconnection
@Override public int getConnectTimeout() {
return delegate.getConnectTimeout();
}
代码示例来源:origin: jenkinsci/ghprb-plugin
public HttpURLConnection connect(URL url) throws IOException {
HttpURLConnection con = (HttpURLConnection) ProxyConfiguration.open(url);
// Set default timeouts in case there are none
if (con.getConnectTimeout() == 0) {
con.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT);
}
if (con.getReadTimeout() == 0) {
con.setReadTimeout(DEFAULT_READ_TIMEOUT);
}
return con;
}
}
代码示例来源:origin: timols/java-gitlab-api
@Test
@DisplayName(value = "Expected success, calling the \"setupConnection\" method if the connection timeout > 0")
public void unitTest_20180503194559() throws Exception {
GitlabAPI api = mock(GitlabAPI.class);
when(api.getConnectionTimeout()).thenReturn(456);
GitlabHTTPRequestor http = new GitlabHTTPRequestor(api);
URL url = new URL("http://test.url");
Method method = GitlabHTTPRequestor.class.getDeclaredMethod("setupConnection", URL.class);
method.setAccessible(true);
HttpURLConnection connection = (HttpURLConnection) method.invoke(http, url);
assertThat(connection.getConnectTimeout(), is(456));
}
代码示例来源:origin: timols/java-gitlab-api
@Test
@DisplayName(value = "Expected success, calling the \"setupConnection\" method if the connection timeout = 0")
public void unitTest_20180503194340() throws Exception {
GitlabAPI api = mock(GitlabAPI.class);
when(api.getConnectionTimeout()).thenReturn(0);
GitlabHTTPRequestor http = new GitlabHTTPRequestor(api);
URL url = new URL("http://test.url");
Method method = GitlabHTTPRequestor.class.getDeclaredMethod("setupConnection", URL.class);
method.setAccessible(true);
HttpURLConnection connection = (HttpURLConnection) method.invoke(http, url);
assertThat(connection.getConnectTimeout(), is(0));
}
代码示例来源:origin: braintree/braintree_android
@Test(timeout = 1000)
public void setsDefaultConnectTimeoutWhenNoTimeoutIsSet() throws IOException {
HttpClient httpClient = new HttpClient();
HttpURLConnection connection = httpClient.init("http://example.com/");
assertEquals(30000, connection.getConnectTimeout());
}
代码示例来源:origin: braintree/braintree_android
@Test
public void setsConnectTimeout() throws IOException {
PayPalHttpClient httpClient = new PayPalHttpClient();
HttpURLConnection connection = httpClient.init("http://example.com");
assertEquals(90000, connection.getConnectTimeout());
}
}
代码示例来源:origin: braintree/braintree_android
@Test(timeout = 1000)
public void setsConnectTimeout() throws IOException {
HttpClient httpClient = new HttpClient()
.setConnectTimeout(1000);
HttpURLConnection connection = httpClient.init("http://example.com/");
assertEquals(1000, connection.getConnectTimeout());
}
代码示例来源:origin: tus/tus-java-client
@Test
public void testSetConnectionTimeout() throws IOException {
HttpURLConnection connection = (HttpURLConnection) mockServerURL.openConnection();
TusClient client = new TusClient();
assertEquals(client.getConnectTimeout(), 5000);
client.setConnectTimeout(3000);
assertEquals(client.getConnectTimeout(), 3000);
client.prepareConnection(connection);
assertEquals(connection.getConnectTimeout(), 3000);
}
内容来源于网络,如有侵权,请联系作者删除!