okhttp3.Request.isHttps()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(310)

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

Request.isHttps介绍

暂无

代码示例

代码示例来源:origin: square/okhttp

/**
 * Returns true if the request line should contain the full URL with host and port (like "GET
 * http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

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

/**
 * Returns true if the request line should contain the full URL with host and port (like "GET
 * http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: square/okhttp

final Headers headers = withSyntheticHeaders(response);
final ResponseBody body = response.body();
if (response.request().isHttps()) {
 final Handshake handshake = response.handshake();
 return new SecureCacheResponse() {

代码示例来源:origin: square/okhttp

/**
 * Creates an {@link java.net.HttpURLConnection} of the correct subclass from the supplied OkHttp
 * {@link Response}.
 */
static HttpURLConnection createJavaUrlConnectionForCachePut(Response okResponse) {
 okResponse = okResponse.newBuilder()
   .body(null)
   .headers(withSyntheticHeaders(okResponse))
   .build();
 Request request = okResponse.request();
 // Create an object of the correct class in case the ResponseCache uses instanceof.
 if (request.isHttps()) {
  return new CacheHttpsURLConnection(new CacheHttpURLConnection(okResponse));
 } else {
  return new CacheHttpURLConnection(okResponse);
 }
}

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

/**
 * Returns a Map of flowfile attributes from the response http headers. Multivalue headers are naively converted to comma separated strings.
 */
private Map<String, String> convertAttributesFromHeaders(URL url, Response responseHttp){
  // create a new hashmap to store the values from the connection
  Map<String, String> map = new HashMap<>();
  responseHttp.headers().names().forEach( (key) -> {
      if (key == null) {
        return;
      }
      List<String> values = responseHttp.headers().values(key);
      // we ignore any headers with no actual values (rare)
      if (values == null || values.isEmpty()) {
        return;
      }
      // create a comma separated string from the values, this is stored in the map
      String value = csv(values);
      // put the csv into the map
      map.put(key, value);
  });
  if (responseHttp.request().isHttps()) {
    Principal principal = responseHttp.handshake().peerPrincipal();
    if (principal != null) {
      map.put(REMOTE_DN, principal.getName());
    }
  }
  return map;
}

代码示例来源:origin: square/okhttp

if (request.isHttps() && cacheResponse.handshake() == null) {
 return new CacheStrategy(request, null);

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

if (request.isHttps() && cacheResponse.handshake() == null) {
 return new CacheStrategy(request, null);

代码示例来源:origin: huxq17/SwipeCardsView

/**
 * Returns true if the request line should contain the full URL with host
 * and port (like "GET http://android.com/foo HTTP/1.1") or only the path
 * (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: com.github.ljun20160606/okhttp

/**
 * Returns true if the request line should contain the full URL with host and port (like "GET
 * http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: huxq17/tractor

/**
 * Returns true if the request line should contain the full URL with host
 * and port (like "GET http://android.com/foo HTTP/1.1") or only the path
 * (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Returns true if the request line should contain the full URL with host and port (like "GET
 * http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: duzechao/OKHttpUtils

/**
 * Returns true if the request line should contain the full URL with host and port (like "GET
 * http://android.com/foo HTTP/1.1") or only the path (like "GET /foo HTTP/1.1").
 */
private static boolean includeAuthorityInRequestLine(Request request, Proxy.Type proxyType) {
 return !request.isHttps() && proxyType == Proxy.Type.HTTP;
}

代码示例来源:origin: charbgr/SeismicInterceptor

private void setupRequestValues() {
  this.httpVerb = request.method();
  this.httpsBadgeTintColor = ContextCompat.getColor(
      context, request.isHttps() ? R.color.gray_30 : R.color.gray_70
  );
}

代码示例来源:origin: net.sf.sprockets/sprockets

private void setHeaders(Request request, URL url, URLConnection con) {
  Headers headers = request.headers();
  for (String header : headers.names()) {
    // TODO_: Support multiple values/header
    con.setRequestProperty(header, headers.get(header));
  }
  // HttpsUrlConnection isn't supported on App Engine, so add a new Header to fix that.
  if (request.isHttps()) {
    int port = url.getPort();
    if (port == -1) {
      port = 443;
    }
    con.setRequestProperty("Host", url.getHost() + ":" + port);
  }
}

代码示例来源:origin: pushbit/sprockets

private void setHeaders(Request request, URL url, URLConnection con) {
  Headers headers = request.headers();
  for (String header : headers.names()) {
    // TODO_: Support multiple values/header
    con.setRequestProperty(header, headers.get(header));
  }
  // HttpsUrlConnection isn't supported on App Engine, so add a new Header to fix that.
  if (request.isHttps()) {
    int port = url.getPort();
    if (port == -1) {
      port = 443;
    }
    con.setRequestProperty("Host", url.getHost() + ":" + port);
  }
}

代码示例来源:origin: io.takari.aether/aether-connector-okhttp

private Request authenticateProxy(Proxy proxy, okhttp3.Response response)
   throws IOException {
   Request req = response.request();
   if(req.header("Proxy-Authorization") == null && config.getProxy() != null && 
     config.getProxy().getAuthentication() != null) {
    String value = toHeaderValue(config.getProxy().getAuthentication());
    
    boolean tunneled = req.isHttps() && proxy.type() == Type.HTTP;
    if(!tunneled) {
     // start including proxy-auth on each request
     headers.put("Proxy-Authorization", value);
    }
    
    return req.newBuilder().header("Proxy-Authorization", value).build();
   }
   return null;
 }
};

代码示例来源:origin: com.squareup.okhttp3/okhttp-android-support

/**
 * Creates an {@link java.net.HttpURLConnection} of the correct subclass from the supplied OkHttp
 * {@link Response}.
 */
static HttpURLConnection createJavaUrlConnectionForCachePut(Response okResponse) {
 okResponse = okResponse.newBuilder()
   .body(null)
   .headers(withSyntheticHeaders(okResponse))
   .build();
 Request request = okResponse.request();
 // Create an object of the correct class in case the ResponseCache uses instanceof.
 if (request.isHttps()) {
  return new CacheHttpsURLConnection(new CacheHttpURLConnection(okResponse));
 } else {
  return new CacheHttpURLConnection(okResponse);
 }
}

代码示例来源:origin: duzechao/OKHttpUtils

private static Address createAddress(OkHttpClient client, Request request) {
  SSLSocketFactory sslSocketFactory = null;
  HostnameVerifier hostnameVerifier = null;
  CertificatePinner certificatePinner = null;
  if (request.isHttps()) {
   sslSocketFactory = client.sslSocketFactory();
   hostnameVerifier = client.hostnameVerifier();
   certificatePinner = client.certificatePinner();
  }

  return new Address(request.url().host(), request.url().port(), client.dns(),
    client.socketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner,
    client.proxyAuthenticator(), client.proxy(), client.protocols(),
    client.connectionSpecs(), client.proxySelector());
 }
}

代码示例来源:origin: huxq17/tractor

private static Address createAddress(OkHttpClient client, Request request) {
  SSLSocketFactory sslSocketFactory = null;
  HostnameVerifier hostnameVerifier = null;
  CertificatePinner certificatePinner = null;
  if (request.isHttps()) {
   sslSocketFactory = client.getSslSocketFactory();
   hostnameVerifier = client.getHostnameVerifier();
   certificatePinner = client.getCertificatePinner();
  }

  return new Address(request.url().host(), request.url().port(), client.getDns(),
    client.getSocketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner,
    client.getAuthenticator(), client.getProxy(), client.getProtocols(),
    client.getConnectionSpecs(), client.getProxySelector());
 }
}

代码示例来源:origin: huxq17/SwipeCardsView

private static Address createAddress(OkHttpClient client, Request request) {
  SSLSocketFactory sslSocketFactory = null;
  HostnameVerifier hostnameVerifier = null;
  CertificatePinner certificatePinner = null;
  if (request.isHttps()) {
   sslSocketFactory = client.getSslSocketFactory();
   hostnameVerifier = client.getHostnameVerifier();
   certificatePinner = client.getCertificatePinner();
  }

  return new Address(request.url().host(), request.url().port(), client.getDns(),
    client.getSocketFactory(), sslSocketFactory, hostnameVerifier, certificatePinner,
    client.getAuthenticator(), client.getProxy(), client.getProtocols(),
    client.getConnectionSpecs(), client.getProxySelector());
 }
}

相关文章