當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClientBuilder.setServiceUnavailableRetryStrategy方法代碼示例

本文整理匯總了Java中org.apache.http.impl.client.HttpClientBuilder.setServiceUnavailableRetryStrategy方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClientBuilder.setServiceUnavailableRetryStrategy方法的具體用法?Java HttpClientBuilder.setServiceUnavailableRetryStrategy怎麽用?Java HttpClientBuilder.setServiceUnavailableRetryStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.client.HttpClientBuilder的用法示例。


在下文中一共展示了HttpClientBuilder.setServiceUnavailableRetryStrategy方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
protected Drive connect(final HostKeyCallback callback, final LoginCallback prompt) {
    authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol())
        .withRedirectUri(host.getProtocol().getOAuthRedirectUrl());
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.addInterceptorLast(authorizationService);
    configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
    this.transport = new ApacheHttpTransport(configuration.build());
    return new Drive.Builder(transport, json, new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest request) throws IOException {
            request.setSuppressUserAgentSuffix(true);
            // OAuth Bearer added in interceptor
        }
    })
        .setApplicationName(useragent.get())
        .build();
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:19,代碼來源:DriveSession.java

示例2: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
protected DbxRawClientV2 connect(final HostKeyCallback callback, final LoginCallback prompt) {
    authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol())
        .withRedirectUri(host.getProtocol().getOAuthRedirectUrl());
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.addInterceptorLast(authorizationService);
    configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
    final CloseableHttpClient client = configuration.build();
    return new DbxRawClientV2(DbxRequestConfig.newBuilder(useragent.get())
        .withAutoRetryDisabled()
        .withHttpRequestor(new DropboxCommonsHttpRequestExecutor(client)).build(), DbxHost.DEFAULT) {
        @Override
        protected void addAuthHeaders(final List<HttpRequestor.Header> headers) {
            // OAuth Bearer added in interceptor
        }
    };
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:18,代碼來源:DropboxSession.java

示例3: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
public B2ApiClient connect(final HostKeyCallback key, final LoginCallback prompt) throws BackgroundException {
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.setServiceUnavailableRetryStrategy(retryHandler = new B2ErrorResponseInterceptor(
        this));
    configuration.addInterceptorLast(retryHandler);
    return new B2ApiClient(configuration.build());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:9,代碼來源:B2Session.java

示例4: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
public RequestEntityRestStorageService connect(final HostKeyCallback key, final LoginCallback prompt) {
    authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol())
        .withRedirectUri(host.getProtocol().getOAuthRedirectUrl());
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.addInterceptorLast(authorizationService);
    configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
    return new OAuth2RequestEntityRestStorageService(this, this.configure(), configuration);
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:10,代碼來源:GoogleStorageSession.java

示例5: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
public Client connect(final HostKeyCallback key, final LoginCallback prompt) {
    authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol())
        .withRedirectUri(host.getProtocol().getOAuthRedirectUrl());
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.addInterceptorLast(authorizationService);
    configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
    return new Client(configuration.build());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:10,代碼來源:HubicSession.java

示例6: connect

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
@Override
protected OneDriveAPI connect(final HostKeyCallback key, final LoginCallback prompt) {
    authorizationService = new OAuth2RequestInterceptor(builder.build(this, prompt).build(), host.getProtocol()) {
        @Override
        public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
            if(request.containsHeader(HttpHeaders.AUTHORIZATION)) {
                super.process(request, context);
            }
        }
    }.withRedirectUri(host.getProtocol().getOAuthRedirectUrl());
    final HttpClientBuilder configuration = builder.build(this, prompt);
    configuration.addInterceptorLast(authorizationService);
    configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(authorizationService));
    final RequestExecutor executor = new OneDriveCommonsHttpRequestExecutor(configuration.build()) {
        @Override
        public void addAuthorizationHeader(final Set<RequestHeader> headers) {
            // Placeholder
            headers.add(new RequestHeader(HttpHeaders.AUTHORIZATION, "Bearer"));
        }
    };
    return new OneDriveAPI() {
        @Override
        public RequestExecutor getExecutor() {
            return executor;
        }

        @Override
        public boolean isBusinessConnection() {
            return false;
        }

        @Override
        public boolean isGraphConnection() {
            return StringUtils.equals("graph.microsoft.com", host.getHostname());
        }

        @Override
        public String getBaseURL() {
            return String.format("%s://%s%s", host.getProtocol().getScheme(), host.getHostname(), host.getProtocol().getContext());
        }

        @Override
        public String getEmailURL() {
            return null;
        }
    };
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:48,代碼來源:OneDriveSession.java

示例7: build

import org.apache.http.impl.client.HttpClientBuilder; //導入方法依賴的package包/類
/**
 * @param listener Log listener
 * @param prompt   Prompt for proxy credentials
 * @return Builder for HTTP client
 */
public HttpClientBuilder build(final TranscriptListener listener, final LoginCallback prompt) {
    final HttpClientBuilder configuration = HttpClients.custom();
    // Use HTTP Connect proxy implementation provided here instead of
    // relying on internal proxy support in socket factory
    final Proxy proxy = proxyFinder.find(host);
    switch(proxy.getType()) {
        case HTTP:
        case HTTPS:
            final HttpHost h = new HttpHost(proxy.getHostname(), proxy.getPort(), StringUtils.lowerCase(proxy.getType().name()));
            if(log.isInfoEnabled()) {
                log.info(String.format("Setup proxy %s", h));
            }
            configuration.setProxy(h);
            configuration.setProxyAuthenticationStrategy(new CallbackProxyAuthenticationStrategy(ProxyCredentialsStoreFactory.get(), host, prompt));
            break;
    }
    configuration.setUserAgent(new PreferencesUseragentProvider().get());
    final int timeout = preferences.getInteger("connection.timeout.seconds") * 1000;
    configuration.setDefaultSocketConfig(SocketConfig.custom()
        .setTcpNoDelay(true)
        .setSoTimeout(timeout)
        .build());
    configuration.setDefaultRequestConfig(this.createRequestConfig(timeout));
    final String encoding;
    if(null == host.getEncoding()) {
        encoding = preferences.getProperty("browser.charset.encoding");
    }
    else {
        encoding = host.getEncoding();
    }
    configuration.setDefaultConnectionConfig(ConnectionConfig.custom()
        .setBufferSize(preferences.getInteger("http.socket.buffer"))
        .setCharset(Charset.forName(encoding))
        .build());
    if(preferences.getBoolean("http.connections.reuse")) {
        configuration.setConnectionReuseStrategy(new DefaultClientConnectionReuseStrategy());
    }
    else {
        configuration.setConnectionReuseStrategy(new NoConnectionReuseStrategy());
    }
    configuration.setRetryHandler(new ExtendedHttpRequestRetryHandler(preferences.getInteger("http.connections.retry")));
    configuration.setServiceUnavailableRetryStrategy(new DisabledServiceUnavailableRetryStrategy());
    if(!preferences.getBoolean("http.compression.enable")) {
        configuration.disableContentCompression();
    }
    configuration.setRequestExecutor(new LoggingHttpRequestExecutor(listener));
    // Always register HTTP for possible use with proxy. Contains a number of protocol properties such as the
    // default port and the socket factory to be used to create the java.net.Socket instances for the given protocol
    configuration.setConnectionManager(this.createConnectionManager(this.createRegistry()));
    configuration.setDefaultAuthSchemeRegistry(RegistryBuilder.<AuthSchemeProvider>create()
        .register(AuthSchemes.BASIC, new BasicSchemeFactory(
            Charset.forName(preferences.getProperty("http.credentials.charset"))))
        .register(AuthSchemes.DIGEST, new DigestSchemeFactory(
            Charset.forName(preferences.getProperty("http.credentials.charset"))))
        .register(AuthSchemes.NTLM, new NTLMSchemeFactory())
        .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory())
        .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory()).build());
    return configuration;
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:65,代碼來源:HttpConnectionPoolBuilder.java


注:本文中的org.apache.http.impl.client.HttpClientBuilder.setServiceUnavailableRetryStrategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。