/** * 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; }
/** * 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; }
final Headers headers = withSyntheticHeaders(response); final ResponseBody body = response.body(); if (response.request().isHttps()) { final Handshake handshake = response.handshake(); return new SecureCacheResponse() {
/** * 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); } }
/** * 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; }
if (request.isHttps() && cacheResponse.handshake() == null) { return new CacheStrategy(request, null);
if (request.isHttps() && cacheResponse.handshake() == null) { return new CacheStrategy(request, null);
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
private void setupRequestValues() { this.httpVerb = request.method(); this.httpsBadgeTintColor = ContextCompat.getColor( context, request.isHttps() ? R.color.gray_30 : R.color.gray_70 ); }
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); } }
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); } }
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; } };
/** * 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); } }
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()); } }
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()); } }
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()); } }