Search in sources :

Example 1 with NoConnectionReuseStrategyHC4

use of org.apache.http.impl.NoConnectionReuseStrategyHC4 in project Signal-Android by signalapp.

the class LegacyMmsConnection method constructHttpClient.

protected CloseableHttpClient constructHttpClient() throws IOException {
    RequestConfig config = RequestConfig.custom().setConnectTimeout(20 * 1000).setConnectionRequestTimeout(20 * 1000).setSocketTimeout(20 * 1000).setMaxRedirects(20).build();
    URL mmsc = new URL(apn.getMmsc());
    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    if (apn.hasAuthentication()) {
        credsProvider.setCredentials(new AuthScope(mmsc.getHost(), mmsc.getPort() > -1 ? mmsc.getPort() : mmsc.getDefaultPort()), new UsernamePasswordCredentials(apn.getUsername(), apn.getPassword()));
    }
    return HttpClients.custom().setConnectionReuseStrategy(new NoConnectionReuseStrategyHC4()).setRedirectStrategy(new LaxRedirectStrategy()).setUserAgent(TextSecurePreferences.getMmsUserAgent(context, USER_AGENT)).setConnectionManager(new BasicHttpClientConnectionManager()).setDefaultRequestConfig(config).setDefaultCredentialsProvider(credsProvider).build();
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) NoConnectionReuseStrategyHC4(org.apache.http.impl.NoConnectionReuseStrategyHC4) AuthScope(org.apache.http.auth.AuthScope) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) LaxRedirectStrategy(org.apache.http.impl.client.LaxRedirectStrategy) URL(java.net.URL) BasicHttpClientConnectionManager(org.apache.http.impl.conn.BasicHttpClientConnectionManager) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Example 2 with NoConnectionReuseStrategyHC4

use of org.apache.http.impl.NoConnectionReuseStrategyHC4 in project Signal-Android by WhisperSystems.

the class LegacyMmsConnection method constructHttpClient.

protected CloseableHttpClient constructHttpClient() throws IOException {
    RequestConfig config = RequestConfig.custom().setConnectTimeout(20 * 1000).setConnectionRequestTimeout(20 * 1000).setSocketTimeout(20 * 1000).setMaxRedirects(20).build();
    URL mmsc = new URL(apn.getMmsc());
    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    if (apn.hasAuthentication()) {
        credsProvider.setCredentials(new AuthScope(mmsc.getHost(), mmsc.getPort() > -1 ? mmsc.getPort() : mmsc.getDefaultPort()), new UsernamePasswordCredentials(apn.getUsername(), apn.getPassword()));
    }
    return HttpClients.custom().setConnectionReuseStrategy(new NoConnectionReuseStrategyHC4()).setRedirectStrategy(new LaxRedirectStrategy()).setUserAgent(TextSecurePreferences.getMmsUserAgent(context, USER_AGENT)).setConnectionManager(new BasicHttpClientConnectionManager()).setDefaultRequestConfig(config).setDefaultCredentialsProvider(credsProvider).build();
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) NoConnectionReuseStrategyHC4(org.apache.http.impl.NoConnectionReuseStrategyHC4) AuthScope(org.apache.http.auth.AuthScope) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) LaxRedirectStrategy(org.apache.http.impl.client.LaxRedirectStrategy) URL(java.net.URL) BasicHttpClientConnectionManager(org.apache.http.impl.conn.BasicHttpClientConnectionManager) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

URL (java.net.URL)2 AuthScope (org.apache.http.auth.AuthScope)2 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)2 CredentialsProvider (org.apache.http.client.CredentialsProvider)2 RequestConfig (org.apache.http.client.config.RequestConfig)2 NoConnectionReuseStrategyHC4 (org.apache.http.impl.NoConnectionReuseStrategyHC4)2 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)2 LaxRedirectStrategy (org.apache.http.impl.client.LaxRedirectStrategy)2 BasicHttpClientConnectionManager (org.apache.http.impl.conn.BasicHttpClientConnectionManager)2