If you think the Android project popcorn-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*/*fromwww.java2s.com*/
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.squareup.okhttp.internal.http;
import com.squareup.okhttp.Connection;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.TunnelRequest;
import java.io.IOException;
import java.net.CacheResponse;
import java.net.SecureCacheResponse;
import java.net.URL;
import javax.net.ssl.SSLSocket;
importstatic com.squareup.okhttp.internal.Util.getEffectivePort;
publicfinalclass HttpsEngine extends HttpEngine {
/**
* Stash of HttpsEngine.connection.socket to implement requests like {@code
* HttpsURLConnection#getCipherSuite} even after the connection has been
* recycled.
*/private SSLSocket sslSocket;
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders,
Connection connection, RetryableOutputStream requestBody) throws IOException {
super(client, policy, method, requestHeaders, connection, requestBody);
this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null;
}
@Override protectedvoid connected(Connection connection) {
this.sslSocket = (SSLSocket) connection.getSocket();
super.connected(connection);
}
@Override protectedboolean acceptCacheResponseType(CacheResponse cacheResponse) {
return cacheResponse instanceof SecureCacheResponse;
}
@Override protectedboolean includeAuthorityInRequestLine() {
// Even if there is a proxy, it isn't involved. Always request just the path.
return false;
}
public SSLSocket getSslSocket() {
return sslSocket;
}
@Override protected TunnelRequest getTunnelConfig() {
String userAgent = requestHeaders.getUserAgent();
if (userAgent == null) {
userAgent = getDefaultUserAgent();
}
URL url = policy.getURL();
returnnew TunnelRequest(url.getHost(), getEffectivePort(url), userAgent,
requestHeaders.getProxyAuthorization());
}
}