File tree Expand file tree Collapse file tree 6 files changed +36
-21
lines changed
src/org/openqa/selenium/remote
server/src/org/openqa/selenium/remote/server Expand file tree Collapse file tree 6 files changed +36
-21
lines changed Original file line number Diff line number Diff line change 46
46
47
47
public class HttpCommandExecutor implements CommandExecutor , NeedsLocalLogs {
48
48
49
- private final static HttpClient .Factory defaultClientFactory ;
50
- static {
51
- String defaultFactory = System .getProperty ("webdriver.http.factory" , "okhttp" );
52
- switch (defaultFactory ) {
53
- case "okhttp" :
54
- defaultClientFactory = new OkHttpClient .Factory ();
55
- break ;
56
-
57
- case "apache" :
58
- default :
59
- defaultClientFactory = new ApacheHttpClient .Factory ();
60
- break ;
61
- }
62
- }
49
+ private final static HttpClient .Factory defaultClientFactory = HttpClient .Factory .createDefault ();
63
50
64
51
private final URL remoteServer ;
65
52
private final HttpClient client ;
Original file line number Diff line number Diff line change 17
17
18
18
package org .openqa .selenium .remote .http ;
19
19
20
+ import org .openqa .selenium .remote .internal .ApacheHttpClient ;
21
+ import org .openqa .selenium .remote .internal .OkHttpClient ;
22
+
20
23
import java .io .IOException ;
21
24
import java .net .URL ;
22
25
@@ -58,6 +61,18 @@ public interface HttpClient {
58
61
59
62
interface Factory {
60
63
64
+ static Factory createDefault () {
65
+ String defaultFactory = System .getProperty ("webdriver.http.factory" , "okhttp" );
66
+ switch (defaultFactory ) {
67
+ case "okhttp" :
68
+ return new OkHttpClient .Factory ();
69
+
70
+ case "apache" :
71
+ default :
72
+ return new ApacheHttpClient .Factory ();
73
+ }
74
+ }
75
+
61
76
/**
62
77
* Creates a HTTP client that will send requests to the given URL.
63
78
*
Original file line number Diff line number Diff line change 33
33
import org .openqa .selenium .remote .http .HttpMethod ;
34
34
import org .openqa .selenium .remote .http .HttpRequest ;
35
35
import org .openqa .selenium .remote .http .HttpResponse ;
36
- import org .openqa .selenium .remote .internal .ApacheHttpClient ;
37
36
import org .openqa .selenium .testing .InProject ;
38
37
import org .seleniumhq .jetty9 .http .HttpVersion ;
39
38
import org .seleniumhq .jetty9 .http .MimeTypes ;
@@ -206,7 +205,7 @@ public String create(Page page) {
206
205
converted .addProperty ("content" , page .toString ());
207
206
byte [] data = converted .toString ().getBytes (UTF_8 );
208
207
209
- HttpClient client = new ApacheHttpClient .Factory ().createClient (new URL (whereIs ("/" )));
208
+ HttpClient client = HttpClient .Factory . createDefault ().createClient (new URL (whereIs ("/" )));
210
209
HttpRequest request = new HttpRequest (HttpMethod .POST , "/common/createPage" );
211
210
request .setHeader (CONTENT_TYPE , JSON_UTF_8 .toString ());
212
211
request .setContent (data );
Original file line number Diff line number Diff line change 27
27
import org .openqa .selenium .remote .http .HttpMethod ;
28
28
import org .openqa .selenium .remote .http .HttpRequest ;
29
29
import org .openqa .selenium .remote .http .HttpResponse ;
30
- import org .openqa .selenium .remote .internal .ApacheHttpClient ;
31
30
import org .openqa .selenium .support .ui .FluentWait ;
32
31
import org .openqa .selenium .support .ui .Wait ;
33
32
@@ -82,7 +81,7 @@ private synchronized void startServers() {
82
81
}
83
82
84
83
// Keep polling the status page of the hub until it claims to be ready
85
- HttpClient client = new ApacheHttpClient .Factory ().createClient (hub .getWebDriverUrl ());
84
+ HttpClient client = HttpClient .Factory . createDefault ().createClient (hub .getWebDriverUrl ());
86
85
Json json = new Json ();
87
86
Wait <HttpClient > wait = new FluentWait <>(client )
88
87
.ignoring (RuntimeException .class )
Original file line number Diff line number Diff line change 29
29
import org .openqa .selenium .remote .http .HttpResponse ;
30
30
import org .openqa .selenium .remote .internal .ApacheHttpClient ;
31
31
import org .openqa .selenium .remote .internal .JsonToWebElementConverter ;
32
+ import org .openqa .selenium .remote .internal .OkHttpClient ;
32
33
33
34
import java .io .IOException ;
34
35
import java .net .URL ;
35
36
import java .util .Map ;
36
37
37
38
class ProtocolConverter implements SessionCodec {
38
39
40
+ private final static HttpClient .Factory defaultClientFactory ;
41
+ static {
42
+ String defaultFactory = System .getProperty ("webdriver.http.factory" , "okhttp" );
43
+ switch (defaultFactory ) {
44
+ case "okhttp" :
45
+ defaultClientFactory = new OkHttpClient .Factory ();
46
+ break ;
47
+
48
+ case "apache" :
49
+ default :
50
+ defaultClientFactory = new ApacheHttpClient .Factory ();
51
+ break ;
52
+ }
53
+ }
54
+
39
55
private final static ImmutableSet <String > IGNORED_REQ_HEADERS = ImmutableSet .<String >builder ()
40
56
.add ("connection" )
41
57
.add ("keep-alive" )
@@ -66,7 +82,7 @@ public ProtocolConverter(
66
82
this .downstreamResponse = downstreamResponse ;
67
83
this .upstreamResponse = upstreamResponse ;
68
84
69
- client = new ApacheHttpClient .Factory ().createClient (upstreamUrl );
85
+ client = HttpClient .Factory . createDefault ().createClient (upstreamUrl );
70
86
converter = new JsonToWebElementConverter (null );
71
87
}
72
88
Original file line number Diff line number Diff line change 45
45
import org .openqa .selenium .remote .http .JsonHttpResponseCodec ;
46
46
import org .openqa .selenium .remote .http .W3CHttpCommandCodec ;
47
47
import org .openqa .selenium .remote .http .W3CHttpResponseCodec ;
48
- import org .openqa .selenium .remote .internal .ApacheHttpClient ;
49
48
50
49
import java .io .File ;
51
50
import java .io .IOException ;
@@ -136,7 +135,7 @@ protected Optional<ActiveSession> performHandshake(
136
135
Set <Dialect > downstreamDialects ,
137
136
Capabilities capabilities ) {
138
137
try {
139
- HttpClient client = new ApacheHttpClient .Factory ().createClient (url );
138
+ HttpClient client = HttpClient .Factory . createDefault ().createClient (url );
140
139
141
140
Command command = new Command (
142
141
null ,
You can’t perform that action at this time.
0 commit comments