com.squareup.okhttp.internal.Util.immutableList()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(225)

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

Util.immutableList介绍

暂无

代码示例

代码示例来源:origin: com.squareup.okhttp/mockwebserver

  1. /**
  2. * Indicates the protocols supported by ALPN on incoming HTTPS
  3. * connections. This list is ignored when
  4. * {@link #setProtocolNegotiationEnabled negotiation is disabled}.
  5. *
  6. * @param protocols the protocols to use, in order of preference. The list
  7. * must contain {@linkplain Protocol#HTTP_1_1}. It must not contain null.
  8. */
  9. public void setProtocols(List<Protocol> protocols) {
  10. protocols = Util.immutableList(protocols);
  11. if (!protocols.contains(Protocol.HTTP_1_1)) {
  12. throw new IllegalArgumentException("protocols doesn't contain http/1.1: " + protocols);
  13. }
  14. if (protocols.contains(null)) {
  15. throw new IllegalArgumentException("protocols must not contain null");
  16. }
  17. this.protocols = protocols;
  18. }

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

  1. /**
  2. * Constructor.
  3. * @param metricsServer
  4. */
  5. public HawkularMetricsClient(URL metricsServer) {
  6. this.serverUrl = metricsServer;
  7. httpClient = new OkHttpClient();
  8. httpClient.setReadTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
  9. httpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
  10. httpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
  11. httpClient.setFollowRedirects(true);
  12. httpClient.setFollowSslRedirects(true);
  13. httpClient.setProxySelector(ProxySelector.getDefault());
  14. httpClient.setCookieHandler(CookieHandler.getDefault());
  15. httpClient.setCertificatePinner(CertificatePinner.DEFAULT);
  16. httpClient.setAuthenticator(AuthenticatorAdapter.INSTANCE);
  17. httpClient.setConnectionPool(ConnectionPool.getDefault());
  18. httpClient.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
  19. httpClient.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
  20. httpClient.setSocketFactory(SocketFactory.getDefault());
  21. Internal.instance.setNetwork(httpClient, Network.DEFAULT);
  22. }

代码示例来源:origin: io.apiman/apiman-common-net

  1. /**
  2. * Constructor.
  3. * @param metricsServer
  4. */
  5. public HawkularMetricsClient(URL metricsServer) {
  6. this.serverUrl = metricsServer;
  7. httpClient = new OkHttpClient();
  8. httpClient.setReadTimeout(DEFAULT_READ_TIMEOUT, TimeUnit.SECONDS);
  9. httpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT, TimeUnit.SECONDS);
  10. httpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS);
  11. httpClient.setFollowRedirects(true);
  12. httpClient.setFollowSslRedirects(true);
  13. httpClient.setProxySelector(ProxySelector.getDefault());
  14. httpClient.setCookieHandler(CookieHandler.getDefault());
  15. httpClient.setCertificatePinner(CertificatePinner.DEFAULT);
  16. httpClient.setAuthenticator(AuthenticatorAdapter.INSTANCE);
  17. httpClient.setConnectionPool(ConnectionPool.getDefault());
  18. httpClient.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
  19. httpClient.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
  20. httpClient.setSocketFactory(SocketFactory.getDefault());
  21. Internal.instance.setNetwork(httpClient, Network.DEFAULT);
  22. }

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

  1. /**
  2. * @return a new http client
  3. */
  4. private OkHttpClient createHttpClient() {
  5. OkHttpClient client = new OkHttpClient();
  6. client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS);
  7. client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS);
  8. client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS);
  9. client.setFollowRedirects(connectorOptions.isFollowRedirects());
  10. client.setFollowSslRedirects(connectorOptions.isFollowRedirects());
  11. client.setProxySelector(ProxySelector.getDefault());
  12. client.setCookieHandler(CookieHandler.getDefault());
  13. client.setCertificatePinner(CertificatePinner.DEFAULT);
  14. client.setAuthenticator(AuthenticatorAdapter.INSTANCE);
  15. client.setConnectionPool(ConnectionPool.getDefault());
  16. client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
  17. client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
  18. client.setSocketFactory(SocketFactory.getDefault());
  19. Internal.instance.setNetwork(client, Network.DEFAULT);
  20. return client;
  21. }

代码示例来源:origin: io.apiman/apiman-gateway-platforms-servlet

  1. /**
  2. * @return a new http client
  3. */
  4. private OkHttpClient createHttpClient() {
  5. OkHttpClient client = new OkHttpClient();
  6. client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS);
  7. client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS);
  8. client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS);
  9. client.setFollowRedirects(connectorOptions.isFollowRedirects());
  10. client.setFollowSslRedirects(connectorOptions.isFollowRedirects());
  11. client.setProxySelector(ProxySelector.getDefault());
  12. client.setCookieHandler(CookieHandler.getDefault());
  13. client.setCertificatePinner(CertificatePinner.DEFAULT);
  14. client.setAuthenticator(AuthenticatorAdapter.INSTANCE);
  15. client.setConnectionPool(ConnectionPool.getDefault());
  16. client.setProtocols(Util.immutableList(Protocol.HTTP_1_1));
  17. client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS);
  18. client.setSocketFactory(SocketFactory.getDefault());
  19. Internal.instance.setNetwork(client, Network.DEFAULT);
  20. return client;
  21. }

相关文章