Skip to content

Commit

Permalink
Fixing buck build, and using httpclient directly, without wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Apr 11, 2017
1 parent fd98461 commit cabc6b3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions java/client/test/org/openqa/selenium/environment/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ java_library(name = 'environment',
'//java/client/src/org/openqa/selenium:selenium',
'//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,7 +18,6 @@
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 @@ -27,13 +26,14 @@
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,10 +54,7 @@
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 @@ -200,16 +197,14 @@ public String create(Page page) {
try {
JsonObject converted = new JsonObject();
converted.addProperty("content", page.toString());
HttpClient
client =
new ApacheHttpClient.Factory().createClient(new URL(whereIs("/")));
HttpRequest request = new HttpRequest(HttpMethod.POST, "/common/createPage");
byte[] data = converted.toString().getBytes(UTF_8);
request.setHeader(CONTENT_LENGTH, String.valueOf(data.length));

CloseableHttpClient client = HttpClients.createDefault();
HttpPost request = new HttpPost(whereIs("/common/createPage"));
request.setEntity(new ByteArrayEntity(data));
request.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());
request.setContent(data);
HttpResponse response = client.execute(request, true);
return response.getContentString();
CloseableHttpResponse response = client.execute(request);
return EntityUtils.toString(response.getEntity());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Expand Down
2 changes: 2 additions & 0 deletions third_party/java/httpcomponents/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ 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 cabc6b3

Please sign in to comment.