diff --git a/java/client/src/org/openqa/selenium/remote/BUCK b/java/client/src/org/openqa/selenium/remote/BUCK index 25353e876a250..fb7aeddce519c 100644 --- a/java/client/src/org/openqa/selenium/remote/BUCK +++ b/java/client/src/org/openqa/selenium/remote/BUCK @@ -108,8 +108,6 @@ java_library( "html5/RemoteLocationContext.java", "html5/RemoteSessionStorage.java", "html5/RemoteWebStorage.java", - "internal/OkHttpClient.java", - "internal/OkHttpWebSocket.java", "internal/JsonToWebElementConverter.java", "internal/WebElementToJsonConverter.java", "mobile/RemoteNetworkConnection.java", @@ -135,6 +133,7 @@ java_library( ], deps = [ "//java/client/src/org/openqa/selenium:selenium", + "//java/client/src/org/openqa/selenium/remote/http/okhttp:okhttp", "//third_party/java/guava:guava", ], ) diff --git a/java/client/src/org/openqa/selenium/remote/BUILD.bazel b/java/client/src/org/openqa/selenium/remote/BUILD.bazel index 8001bb6bbe5a3..2cb7c5c344a1d 100644 --- a/java/client/src/org/openqa/selenium/remote/BUILD.bazel +++ b/java/client/src/org/openqa/selenium/remote/BUILD.bazel @@ -71,6 +71,7 @@ java_library( ":capabilities", ":remote-lib", "//java/client/src/org/openqa/selenium:core", + "//java/client/src/org/openqa/selenium/remote/http/okhttp", "//third_party/java/bytebuddy:byte-buddy", "//third_party/java/guava", ], @@ -139,7 +140,6 @@ java_library( "//java/client/src/org/openqa/selenium/remote/http", "//java/client/src/org/openqa/selenium/remote/session", "//third_party/java/guava", - "//third_party/java/okhttp3:okhttp", ], ) diff --git a/java/client/src/org/openqa/selenium/remote/http/HttpClient.java b/java/client/src/org/openqa/selenium/remote/http/HttpClient.java index 03e149e69ed34..402d2a2f2ff6e 100644 --- a/java/client/src/org/openqa/selenium/remote/http/HttpClient.java +++ b/java/client/src/org/openqa/selenium/remote/http/HttpClient.java @@ -42,7 +42,7 @@ static Factory createDefault() { default: try { Class clazz = - Class.forName("org.openqa.selenium.remote.internal.OkHttpClient$Factory") + Class.forName("org.openqa.selenium.remote.http.okhttp.OkHttpClient$Factory") .asSubclass(Factory.class); return clazz.newInstance(); } catch (ReflectiveOperationException e) { diff --git a/java/client/src/org/openqa/selenium/remote/http/okhttp/BUCK b/java/client/src/org/openqa/selenium/remote/http/okhttp/BUCK new file mode 100644 index 0000000000000..055bee9dcbddb --- /dev/null +++ b/java/client/src/org/openqa/selenium/remote/http/okhttp/BUCK @@ -0,0 +1,13 @@ +java_library( + name = "okhttp", + srcs = glob(["*.java"]), + deps = [ + "//java/client/src/org/openqa/selenium/remote/http:http", + "//third_party/java/guava:guava", + "//third_party/java/okhttp3:okhttp", + ], + visibility = [ + "//java/client/src/org/openqa/selenium/remote:", + "//java/client/test/org/openqa/selenium/remote/http/okhttp:", + ], +) diff --git a/java/client/src/org/openqa/selenium/remote/http/okhttp/BUILD.bazel b/java/client/src/org/openqa/selenium/remote/http/okhttp/BUILD.bazel index 98128a5dcc741..238ef6ac0090f 100644 --- a/java/client/src/org/openqa/selenium/remote/http/okhttp/BUILD.bazel +++ b/java/client/src/org/openqa/selenium/remote/http/okhttp/BUILD.bazel @@ -7,6 +7,7 @@ java_library( "//third_party/java/okhttp3:okhttp", ], visibility = [ + "//java/client/src/org/openqa/selenium/remote:__pkg__", "//java/client/test/org/openqa/selenium/remote/http/okhttp:__pkg__", ], ) diff --git a/java/client/src/org/openqa/selenium/remote/internal/OkHttpClient.java b/java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpClient.java similarity index 90% rename from java/client/src/org/openqa/selenium/remote/internal/OkHttpClient.java rename to java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpClient.java index 4f9725fba9d1a..e19407b2a4981 100644 --- a/java/client/src/org/openqa/selenium/remote/internal/OkHttpClient.java +++ b/java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpClient.java @@ -15,12 +15,21 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.remote.internal; +package org.openqa.selenium.remote.http.okhttp; import com.google.common.base.Strings; -import okhttp3.*; +import okhttp3.ConnectionPool; +import okhttp3.Credentials; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.openqa.selenium.remote.http.ClientConfig; +import org.openqa.selenium.remote.http.HttpClient; +import org.openqa.selenium.remote.http.HttpRequest; +import org.openqa.selenium.remote.http.HttpResponse; import org.openqa.selenium.remote.http.WebSocket; -import org.openqa.selenium.remote.http.*; import java.io.IOException; import java.io.UncheckedIOException; @@ -30,7 +39,9 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.openqa.selenium.remote.http.AddSeleniumUserAgent.USER_AGENT; -import static org.openqa.selenium.remote.http.Contents.*; +import static org.openqa.selenium.remote.http.Contents.bytes; +import static org.openqa.selenium.remote.http.Contents.empty; +import static org.openqa.selenium.remote.http.Contents.memoize; public class OkHttpClient implements HttpClient { diff --git a/java/client/src/org/openqa/selenium/remote/internal/OkHttpWebSocket.java b/java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpWebSocket.java similarity index 97% rename from java/client/src/org/openqa/selenium/remote/internal/OkHttpWebSocket.java rename to java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpWebSocket.java index 765bac07db073..407a4ee43d834 100644 --- a/java/client/src/org/openqa/selenium/remote/internal/OkHttpWebSocket.java +++ b/java/client/src/org/openqa/selenium/remote/http/okhttp/OkHttpWebSocket.java @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.remote.internal; +package org.openqa.selenium.remote.http.okhttp; import org.openqa.selenium.remote.http.WebSocket; diff --git a/java/client/test/org/openqa/selenium/remote/BUCK b/java/client/test/org/openqa/selenium/remote/BUCK index 1fab3ad82a513..49457dcdeb4c3 100644 --- a/java/client/test/org/openqa/selenium/remote/BUCK +++ b/java/client/test/org/openqa/selenium/remote/BUCK @@ -13,7 +13,6 @@ java_test( "W3CHandshakeResponseTest.java", "W3CRemoteDriverTest.java", "internal/HttpClientTestBase.java", - "internal/OkHttpClientTest.java", "internal/WebElementToJsonConverterTest.java", ], labels = [ diff --git a/java/client/test/org/openqa/selenium/remote/internal/OkHttpClientTest.java b/java/client/test/org/openqa/selenium/remote/http/okhttp/OkHttpClientTest.java similarity index 90% rename from java/client/test/org/openqa/selenium/remote/internal/OkHttpClientTest.java rename to java/client/test/org/openqa/selenium/remote/http/okhttp/OkHttpClientTest.java index bff0b01e01606..73f8784296ab4 100644 --- a/java/client/test/org/openqa/selenium/remote/internal/OkHttpClientTest.java +++ b/java/client/test/org/openqa/selenium/remote/http/okhttp/OkHttpClientTest.java @@ -15,9 +15,10 @@ // specific language governing permissions and limitations // under the License. -package org.openqa.selenium.remote.internal; +package org.openqa.selenium.remote.http.okhttp; import org.openqa.selenium.remote.http.HttpClient; +import org.openqa.selenium.remote.internal.HttpClientTestBase; public class OkHttpClientTest extends HttpClientTestBase { diff --git a/java/server/src/org/openqa/grid/internal/BaseGridRegistry.java b/java/server/src/org/openqa/grid/internal/BaseGridRegistry.java index 3a16c0fb2e71e..ec44270e57b62 100644 --- a/java/server/src/org/openqa/grid/internal/BaseGridRegistry.java +++ b/java/server/src/org/openqa/grid/internal/BaseGridRegistry.java @@ -18,6 +18,7 @@ package org.openqa.grid.internal; import org.openqa.grid.web.Hub; +import org.openqa.selenium.remote.http.ClientConfig; import org.openqa.selenium.remote.http.HttpClient; import java.net.URL; @@ -62,9 +63,10 @@ public HttpClient getHttpClient(URL url) { @Override public HttpClient getHttpClient(URL url, int connectionTimeout, int readTimeout) { - return httpClientFactory.builder() + return httpClientFactory.createClient( + ClientConfig.defaultConfig() + .baseUrl(url) .connectionTimeout(Duration.ofSeconds(connectionTimeout)) - .readTimeout(Duration.ofSeconds(readTimeout)) - .createClient(url); + .readTimeout(Duration.ofSeconds(readTimeout))); } } diff --git a/third_party/java/okhttp3/BUCK b/third_party/java/okhttp3/BUCK index 979acd16ad833..a658208cad8e3 100644 --- a/third_party/java/okhttp3/BUCK +++ b/third_party/java/okhttp3/BUCK @@ -8,6 +8,7 @@ prebuilt_jar( ], visibility = [ "//java/client/src/org/openqa/selenium/remote:remote-lib", + "//java/client/src/org/openqa/selenium/remote/http/okhttp:", "//third_party/java/contrib:opentracing-okhttp3", ], )