mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +03:00
Improve some code comments (#8361)
This commit is contained in:
@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test
|
|||||||
import org.junit.jupiter.api.extension.RegisterExtension
|
import org.junit.jupiter.api.extension.RegisterExtension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanity test for checking which environment and IDE is picking up.
|
* Validates which environment is used by the IDE.
|
||||||
*/
|
*/
|
||||||
class PlatformRuleTest {
|
class PlatformRuleTest {
|
||||||
@RegisterExtension @JvmField
|
@RegisterExtension @JvmField
|
||||||
|
@@ -18,7 +18,7 @@ package okhttp3.internal.connection
|
|||||||
import okhttp3.Route
|
import okhttp3.Route
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A blacklist of failed routes to avoid when creating a new connection to a target address. This is
|
* A denylist of failed routes to avoid when creating a new connection to a target address. This is
|
||||||
* used so that OkHttp can learn from its mistakes: if there was a failure attempting to connect to
|
* used so that OkHttp can learn from its mistakes: if there was a failure attempting to connect to
|
||||||
* a specific IP address or proxy server, that failure is remembered and alternate routes are
|
* a specific IP address or proxy server, that failure is remembered and alternate routes are
|
||||||
* preferred.
|
* preferred.
|
||||||
|
@@ -112,19 +112,18 @@ object OkHostnameVerifier : HostnameVerifier {
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
var hostname = hostname
|
var hostname = hostname
|
||||||
var pattern = pattern
|
var pattern = pattern
|
||||||
// Basic sanity checks
|
|
||||||
if (hostname.isNullOrEmpty() ||
|
if (hostname.isNullOrEmpty() ||
|
||||||
hostname.startsWith(".") ||
|
hostname.startsWith(".") ||
|
||||||
hostname.endsWith("..")
|
hostname.endsWith("..")
|
||||||
) {
|
) {
|
||||||
// Invalid domain name
|
// Invalid domain name.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (pattern.isNullOrEmpty() ||
|
if (pattern.isNullOrEmpty() ||
|
||||||
pattern.startsWith(".") ||
|
pattern.startsWith(".") ||
|
||||||
pattern.endsWith("..")
|
pattern.endsWith("..")
|
||||||
) {
|
) {
|
||||||
// Invalid pattern/domain name
|
// Invalid pattern.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -840,7 +840,7 @@ class DiskLruCacheTest {
|
|||||||
}
|
}
|
||||||
taskFaker.runNextTask()
|
taskFaker.runNextTask()
|
||||||
|
|
||||||
// Sanity check that a rebuilt journal behaves normally.
|
// Check that a rebuilt journal behaves normally.
|
||||||
assertValue("a", "a", "a")
|
assertValue("a", "a", "a")
|
||||||
assertValue("b", "b", "b")
|
assertValue("b", "b", "b")
|
||||||
}
|
}
|
||||||
|
@@ -28,14 +28,14 @@ import okhttp3.Response;
|
|||||||
public final class CheckHandshake {
|
public final class CheckHandshake {
|
||||||
/** Rejects otherwise-trusted certificates. */
|
/** Rejects otherwise-trusted certificates. */
|
||||||
private static final Interceptor CHECK_HANDSHAKE_INTERCEPTOR = new Interceptor() {
|
private static final Interceptor CHECK_HANDSHAKE_INTERCEPTOR = new Interceptor() {
|
||||||
final Set<String> blacklist = Collections.singleton(
|
final Set<String> denylist = Collections.singleton(
|
||||||
"sha256/afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=");
|
"sha256/afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=");
|
||||||
|
|
||||||
@Override public Response intercept(Chain chain) throws IOException {
|
@Override public Response intercept(Chain chain) throws IOException {
|
||||||
for (Certificate certificate : chain.connection().handshake().peerCertificates()) {
|
for (Certificate certificate : chain.connection().handshake().peerCertificates()) {
|
||||||
String pin = CertificatePinner.pin(certificate);
|
String pin = CertificatePinner.pin(certificate);
|
||||||
if (blacklist.contains(pin)) {
|
if (denylist.contains(pin)) {
|
||||||
throw new IOException("Blacklisted peer certificate: " + pin);
|
throw new IOException("Denylisted peer certificate: " + pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chain.proceed(chain.request());
|
return chain.proceed(chain.request());
|
||||||
|
Reference in New Issue
Block a user