Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a socket abstraction #8410

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apiDump
  • Loading branch information
ean5533 committed May 14, 2024
commit 37f59248b7bd5083ad822333d191904e47a809cf
6 changes: 3 additions & 3 deletions mockwebserver-deprecated/api/mockwebserver.api
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public final class okhttp3/mockwebserver/MockWebServer : org/junit/rules/Externa
public final fun -deprecated_protocols ()Ljava/util/List;
public final fun -deprecated_protocols (Ljava/util/List;)V
public final fun -deprecated_requestCount ()I
public final fun -deprecated_serverSocketFactory (Ljavax/net/ServerSocketFactory;)V
public final fun -deprecated_serverSocketFactory (Lokhttp3/internal/socket/OkioServerSocketFactory;)V
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we hide this in this deprecated API, keep it still in terms of javax.net?

public fun <init> ()V
public fun close ()V
public final fun enqueue (Lokhttp3/mockwebserver/MockResponse;)V
Expand All @@ -80,7 +80,7 @@ public final class okhttp3/mockwebserver/MockWebServer : org/junit/rules/Externa
public final fun getPort ()I
public final fun getProtocolNegotiationEnabled ()Z
public final fun getRequestCount ()I
public final fun getServerSocketFactory ()Ljavax/net/ServerSocketFactory;
public final fun getServerSocketFactory ()Lokhttp3/internal/socket/OkioServerSocketFactory;
public final fun noClientAuth ()V
public final fun protocols ()Ljava/util/List;
public final fun requestClientAuth ()V
Expand All @@ -89,7 +89,7 @@ public final class okhttp3/mockwebserver/MockWebServer : org/junit/rules/Externa
public final fun setDispatcher (Lokhttp3/mockwebserver/Dispatcher;)V
public final fun setProtocolNegotiationEnabled (Z)V
public final fun setProtocols (Ljava/util/List;)V
public final fun setServerSocketFactory (Ljavax/net/ServerSocketFactory;)V
public final fun setServerSocketFactory (Lokhttp3/internal/socket/OkioServerSocketFactory;)V
public final fun shutdown ()V
public final fun start ()V
public final fun start (I)V
Expand Down
8 changes: 4 additions & 4 deletions mockwebserver/api/mockwebserver3.api
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public final class mockwebserver3/MockWebServer : java/io/Closeable {
public final fun getProtocolNegotiationEnabled ()Z
public final fun getProtocols ()Ljava/util/List;
public final fun getRequestCount ()I
public final fun getServerSocketFactory ()Ljavax/net/ServerSocketFactory;
public final fun getServerSocketFactory ()Lokhttp3/internal/socket/OkioServerSocketFactory;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we feel about breaking changes to MockWebServer public methods?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this new mockwebserver seems fine, we should avoid changes to okhttp3/mockwebserver/* in the deprecated package.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess these APIs in the non deprecated API become experimental APIs, is that ok?

public final fun getStarted ()Z
public final fun noClientAuth ()V
public final fun requestClientAuth ()V
Expand All @@ -116,7 +116,7 @@ public final class mockwebserver3/MockWebServer : java/io/Closeable {
public final fun setDispatcher (Lmockwebserver3/Dispatcher;)V
public final fun setProtocolNegotiationEnabled (Z)V
public final fun setProtocols (Ljava/util/List;)V
public final fun setServerSocketFactory (Ljavax/net/ServerSocketFactory;)V
public final fun setServerSocketFactory (Lokhttp3/internal/socket/OkioServerSocketFactory;)V
public final fun setStarted (Z)V
public final fun shutdown ()V
public final fun start ()V
Expand Down Expand Up @@ -159,8 +159,8 @@ public final class mockwebserver3/QueueDispatcher$Companion {
}

public final class mockwebserver3/RecordedRequest {
public fun <init> (Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;Ljava/io/IOException;)V
public synthetic fun <init> (Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILjava/net/Socket;Ljava/io/IOException;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILokhttp3/internal/socket/OkioSocket;Ljava/io/IOException;)V
public synthetic fun <init> (Ljava/lang/String;Lokhttp3/Headers;Ljava/util/List;JLokio/Buffer;ILokhttp3/internal/socket/OkioSocket;Ljava/io/IOException;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getBody ()Lokio/Buffer;
public final fun getBodySize ()J
public final fun getChunkSizes ()Ljava/util/List;
Expand Down
1 change: 1 addition & 0 deletions okhttp/api/okhttp.api
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public final class okhttp3/ConnectionSpec {
public fun equals (Ljava/lang/Object;)Z
public fun hashCode ()I
public final fun isCompatible (Ljavax/net/ssl/SSLSocket;)Z
public final fun isCompatible (Lokhttp3/internal/socket/OkioSslSocket;)Z
Copy link
Collaborator Author

@ean5533 ean5533 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I tossed a @ExperimentalOkHttpApi on here

public final fun isTls ()Z
public final fun supportsTlsExtensions ()Z
public final fun tlsVersions ()Ljava/util/List;
Expand Down
14 changes: 13 additions & 1 deletion okhttp/src/main/kotlin/okhttp3/ConnectionSpec.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2014 Square, Inc.
* Copyright (C) 2024 Square, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deliberate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's weird. I set up automatic file headers in IJ, it must have decided to update some existing files sometimes... 🤔

Anyway, will revert

*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -168,10 +168,22 @@ class ConnectionSpec internal constructor(
* For protocols, at least one of the [required protocols][tlsVersions] must match the socket's
* enabled protocols.
*/
@ExperimentalOkHttpApi
fun isCompatible(socket: OkioSslSocket): Boolean {
return isCompatible((socket as RealOkioSslSocket).delegate)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth a TODO? feels like something we may want supported in the API in future.

}

/**
* Returns `true` if the socket, as currently configured, supports this connection spec. In
* order for a socket to be compatible the enabled cipher suites and protocols must intersect.
*
* For cipher suites, at least one of the [required cipher suites][cipherSuites] must match the
* socket's enabled cipher suites. If there are no required cipher suites the socket must have at
* least one cipher suite enabled.
*
* For protocols, at least one of the [required protocols][tlsVersions] must match the socket's
* enabled protocols.
*/
fun isCompatible(socket: SSLSocket): Boolean {
if (!isTls) {
return false
Expand Down
Loading