Skip to content

Commit

Permalink
Upgrading little_proxy and netty
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Aug 4, 2017
1 parent 73a2734 commit 6fc2f27
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .idea/libraries/little_proxy.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/libraries/netty.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions java/client/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<classpathentry kind="lib" path="/third-party/java/xerces/xercesImpl-2.11.0.jar" sourcepath="/third-party/java/xerces/xercesImpl-2.11.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/xalan/xalan-2.7.2.jar"/>
<classpathentry kind="lib" path="/third-party/java/commons-fileupload/commons-fileupload-1.2.2.jar" sourcepath="/third-party/java/commons-fileupload/commons-fileupload-1.2.2-src.jar"/>
<classpathentry kind="lib" path="/third-party/java/little_proxy/littleproxy-0.5.3.jar" sourcepath="/third-party/java/little_proxy/littleproxy-0.5.3-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/little_proxy/littleproxy-1.1.2.jar" sourcepath="/third-party/java/little_proxy/littleproxy-1.1.2-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-api-9.4.5.v20170502.jar" sourcepath="/third-party/java/websocket/websocket-api-9.4.5.v20170502-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-client-9.4.5.v20170502.jar" sourcepath="/third-party/java/websocket/websocket-client-9.4.5.v20170502-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/websocket/websocket-common-9.4.5.v20170502.jar" sourcepath="/third-party/java/websocket/websocket-common-9.4.5.v20170502-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/netty/netty-3.5.7.Final.jar"/>
<classpathentry kind="lib" path="/third-party/java/netty/netty-all-4.1.14.Final.jar"/>
<classpathentry kind="lib" path="/third-party/java/xml-apis/xml-apis-1.4.01.jar"/>
<classpathentry kind="lib" path="/third-party/java/mockito/mockito-core-1.9.5.jar"/>
<classpathentry kind="lib" path="/third-party/java/objenesis/objenesis-1.0.jar"/>
Expand Down
50 changes: 33 additions & 17 deletions java/client/test/org/openqa/selenium/testing/ProxyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,24 @@

import com.google.common.collect.Lists;

import org.jboss.netty.handler.codec.http.HttpRequest;
import org.littleshoot.proxy.DefaultHttpProxyServer;
import org.littleshoot.proxy.HttpRequestFilter;
import org.littleshoot.proxy.HttpFilters;
import org.littleshoot.proxy.HttpFiltersAdapter;
import org.littleshoot.proxy.HttpFiltersSourceAdapter;
import org.littleshoot.proxy.HttpProxyServer;
import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.net.PortProber;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;

import java.util.List;

public class ProxyServer {
private DefaultHttpProxyServer proxyServer;
private HttpProxyServer proxyServer;
private final String baseUrl;
private final List<String> uris = Lists.newLinkedList();

Expand All @@ -39,20 +46,29 @@ public ProxyServer() {
String address = new NetworkUtils().getPrivateLocalAddress();
baseUrl = String.format("%s:%d", address, port);

proxyServer = new DefaultHttpProxyServer(port, new HttpRequestFilter() {
@Override
public void filter(HttpRequest httpRequest) {
String uri = httpRequest.getUri();
String[] parts = uri.split("/");
if (parts.length == 0) {
return;
}
String finalPart = parts[parts.length - 1];
uris.add(finalPart);
}
});
proxyServer = DefaultHttpProxyServer.bootstrap().withPort(port)
.withFiltersSource(new HttpFiltersSourceAdapter() {
public HttpFilters filterRequest(HttpRequest originalRequest, ChannelHandlerContext ctx) {
return new HttpFiltersAdapter(originalRequest) {
public HttpResponse clientToProxyRequest(HttpObject httpObject) {
String uri = originalRequest.uri();
String[] parts = uri.split("/");
if (parts.length == 0) {
return null;
}
String finalPart = parts[parts.length - 1];
uris.add(finalPart);
return null;
}

proxyServer.start();
@Override
public HttpObject serverToProxyResponse(HttpObject httpObject) {
return httpObject;
}
};
}
})
.start();
}

public String getBaseUrl() {
Expand Down
2 changes: 1 addition & 1 deletion java/server/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<classpathentry kind="lib" path="/third-party/java/junit/junit-4.12.jar" sourcepath="/third-party/java/junit/junit-4.12-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/commons-logging/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="/third-party/java/jcip_annotations/jcip-annotations-1.0.jar" sourcepath="/third-party/java/jcip_annotations/jcip-annotations-1.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/netty/netty-3.5.7.Final.jar"/>
<classpathentry kind="lib" path="/third-party/java/netty/netty-all-4.1.14.Final.jar"/>
<classpathentry kind="lib" path="/third-party/java/guava/guava-22.0.jar" sourcepath="/third-party/java/guava/guava-22.0-sources.jar"/>
<classpathentry kind="lib" path="/third-party/java/mockito/mockito-core-1.9.5.jar"/>
<classpathentry kind="lib" path="/third-party/java/jetty/jetty-repacked.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion third_party/java/little_proxy/BUCK
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prebuilt_jar(name = 'little_proxy',
binary_jar = 'littleproxy-0.5.3.jar',
binary_jar = 'littleproxy-1.1.2.jar',
deps = [
'//third_party/java/commons:commons-lang3',
'//third_party/java/commons_cli:commons_cli',
Expand Down
Binary file not shown.
Binary file removed third_party/java/little_proxy/littleproxy-0.5.3.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions third_party/java/netty/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prebuilt_jar(name = 'netty',
binary_jar = 'netty-3.5.7.Final.jar',
maven_coords = 'io.netty:netty:3.5.7.Final',
binary_jar = 'netty-all-4.1.14.Final.jar',
maven_coords = 'io.netty:netty-all:4.1.14.Final',
visibility = [
'//java/client/src/org/openqa/selenium/safari:safari',
'//java/client/test/org/openqa/selenium/safari:tests',
Expand Down
Binary file removed third_party/java/netty/netty-3.5.7.Final-src.jar
Binary file not shown.
Binary file removed third_party/java/netty/netty-3.5.7.Final.jar
Binary file not shown.
Binary file not shown.
Binary file added third_party/java/netty/netty-all-4.1.14.Final.jar
Binary file not shown.

0 comments on commit 6fc2f27

Please sign in to comment.