Skip to content

Commit cabc6b3

Browse files
committed
Fixing buck build, and using httpclient directly, without wrapper
1 parent fd98461 commit cabc6b3

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

java/client/test/org/openqa/selenium/environment/BUCK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ java_library(name = 'environment',
44
'//java/client/src/org/openqa/selenium:selenium',
55
'//java/client/test/org/openqa/selenium/testing:helpers',
66
'//third_party/java/commons-fileupload:commons-fileupload',
7+
'//third_party/java/gson:gson',
78
'//third_party/java/guava:guava',
89
'//third_party/java/httpcomponents:httpclient',
10+
'//third_party/java/httpcomponents:httpcore',
911
'//third_party/java/jetty:jetty',
1012
'//third_party/java/servlet:servlet-api',
1113
],

java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.openqa.selenium.environment.webserver;
1919

2020
import static com.google.common.base.Charsets.UTF_8;
21-
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
2221
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
2322
import static com.google.common.net.MediaType.JSON_UTF_8;
2423
import static org.openqa.selenium.net.PortProber.findFreePort;
@@ -27,13 +26,14 @@
2726
import com.google.common.collect.ImmutableList;
2827
import com.google.gson.JsonObject;
2928

29+
import org.apache.http.client.methods.CloseableHttpResponse;
30+
import org.apache.http.client.methods.HttpPost;
31+
import org.apache.http.entity.ByteArrayEntity;
32+
import org.apache.http.impl.client.CloseableHttpClient;
33+
import org.apache.http.impl.client.HttpClients;
34+
import org.apache.http.util.EntityUtils;
3035
import org.openqa.selenium.io.TemporaryFilesystem;
3136
import org.openqa.selenium.net.NetworkUtils;
32-
import org.openqa.selenium.remote.http.HttpClient;
33-
import org.openqa.selenium.remote.http.HttpMethod;
34-
import org.openqa.selenium.remote.http.HttpRequest;
35-
import org.openqa.selenium.remote.http.HttpResponse;
36-
import org.openqa.selenium.remote.internal.ApacheHttpClient;
3737
import org.openqa.selenium.testing.InProject;
3838
import org.seleniumhq.jetty9.http.HttpVersion;
3939
import org.seleniumhq.jetty9.http.MimeTypes;
@@ -54,10 +54,7 @@
5454
import org.seleniumhq.jetty9.util.ssl.SslContextFactory;
5555

5656
import java.io.File;
57-
import java.io.FileWriter;
5857
import java.io.IOException;
59-
import java.io.Writer;
60-
import java.net.URL;
6158
import java.nio.file.Files;
6259
import java.nio.file.Path;
6360
import java.util.EnumSet;
@@ -200,16 +197,14 @@ public String create(Page page) {
200197
try {
201198
JsonObject converted = new JsonObject();
202199
converted.addProperty("content", page.toString());
203-
HttpClient
204-
client =
205-
new ApacheHttpClient.Factory().createClient(new URL(whereIs("/")));
206-
HttpRequest request = new HttpRequest(HttpMethod.POST, "/common/createPage");
207200
byte[] data = converted.toString().getBytes(UTF_8);
208-
request.setHeader(CONTENT_LENGTH, String.valueOf(data.length));
201+
202+
CloseableHttpClient client = HttpClients.createDefault();
203+
HttpPost request = new HttpPost(whereIs("/common/createPage"));
204+
request.setEntity(new ByteArrayEntity(data));
209205
request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());
210-
request.setContent(data);
211-
HttpResponse response = client.execute(request, true);
212-
return response.getContentString();
206+
CloseableHttpResponse response = client.execute(request);
207+
return EntityUtils.toString(response.getEntity());
213208
} catch (IOException ex) {
214209
throw new RuntimeException(ex);
215210
}

third_party/java/httpcomponents/BUCK

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ prebuilt_jar(
2525
visibility = [
2626
# Only made visible because of a bug in prebuilt_jar not exporting deps
2727
'//java/client/src/org/openqa/selenium/remote:remote-lib',
28+
'//java/client/test/...',
29+
'//java/server/test/...',
2830
],
2931
)
3032

0 commit comments

Comments
 (0)