Skip to content

Commit

Permalink
Revert cabc6b3
Browse files Browse the repository at this point in the history
Restore the use of our own abstractions and keep the
visibility of the httpcomponents as limited as
possible.
  • Loading branch information
shs96c committed Apr 11, 2017
1 parent cabc6b3 commit f96cd95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion java/client/test/org/openqa/selenium/environment/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ java_library(name = 'environment',
srcs = glob(['*.java', 'webserver/*.java'], excludes = ['**/*Test.java']),
deps = [
'//java/client/src/org/openqa/selenium:selenium',
'//java/client/src/org/openqa/selenium/remote:remote',
'//java/client/test/org/openqa/selenium/testing:helpers',
'//third_party/java/commons-fileupload:commons-fileupload',
'//third_party/java/gson:gson',
'//third_party/java/guava:guava',
'//third_party/java/httpcomponents:httpclient',
'//third_party/java/httpcomponents:httpcore',
'//third_party/java/jetty:jetty',
'//third_party/java/servlet:servlet-api',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.openqa.selenium.environment.webserver;

import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import static com.google.common.net.MediaType.JSON_UTF_8;
import static org.openqa.selenium.net.PortProber.findFreePort;
Expand All @@ -26,14 +27,13 @@
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject;

import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.openqa.selenium.io.TemporaryFilesystem;
import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.http.HttpMethod;
import org.openqa.selenium.remote.http.HttpRequest;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.internal.ApacheHttpClient;
import org.openqa.selenium.testing.InProject;
import org.seleniumhq.jetty9.http.HttpVersion;
import org.seleniumhq.jetty9.http.MimeTypes;
Expand All @@ -54,7 +54,10 @@
import org.seleniumhq.jetty9.util.ssl.SslContextFactory;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.EnumSet;
Expand Down Expand Up @@ -199,12 +202,12 @@ public String create(Page page) {
converted.addProperty("content", page.toString());
byte[] data = converted.toString().getBytes(UTF_8);

CloseableHttpClient client = HttpClients.createDefault();
HttpPost request = new HttpPost(whereIs("/common/createPage"));
request.setEntity(new ByteArrayEntity(data));
HttpClient client = new ApacheHttpClient.Factory().createClient(new URL(whereIs("/")));
HttpRequest request = new HttpRequest(HttpMethod.POST, "/common/createPage");
request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());
CloseableHttpResponse response = client.execute(request);
return EntityUtils.toString(response.getEntity());
request.setContent(data);
HttpResponse response = client.execute(request, true);
return response.getContentString();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Expand Down
2 changes: 0 additions & 2 deletions third_party/java/httpcomponents/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ prebuilt_jar(
visibility = [
# Only made visible because of a bug in prebuilt_jar not exporting deps
'//java/client/src/org/openqa/selenium/remote:remote-lib',
'//java/client/test/...',
'//java/server/test/...',
],
)

Expand Down

0 comments on commit f96cd95

Please sign in to comment.