Skip to content

Commit

Permalink
First Version
Browse files Browse the repository at this point in the history
  • Loading branch information
ms777 committed Apr 13, 2019
1 parent 679d90d commit e7ab019
Show file tree
Hide file tree
Showing 352 changed files with 113 additions and 80,280 deletions.
465 changes: 72 additions & 393 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.littleshoot.proxy.HttpProxyServer;
import org.littleshoot.proxy.HttpProxyServerBootstrap;
import org.littleshoot.proxy.MitmManager;
import org.littleshoot.proxy.impl.ClientDetails;
import org.littleshoot.proxy.impl.DefaultHttpProxyServer;
import org.littleshoot.proxy.impl.ProxyUtils;
import org.littleshoot.proxy.impl.ThreadPoolConfiguration;
Expand Down Expand Up @@ -339,7 +340,7 @@ public int getMaximumResponseBufferSizeInBytes() {

bootstrap.withChainProxyManager(new ChainedProxyManager() {
@Override
public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies, ClientDetails clientDetails) {
final InetSocketAddress upstreamProxy = upstreamProxyAddress;
if (upstreamProxy != null) {
chainedProxies.add(new ChainedProxyAdapter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package net.lightbody.bmp.client;

import com.google.common.collect.ImmutableList;
import net.lightbody.bmp.BrowserMobProxy;
import net.lightbody.bmp.proxy.dns.AdvancedHostResolver;
import net.lightbody.bmp.proxy.dns.ChainedHostResolver;
import net.lightbody.bmp.proxy.dns.DnsJavaResolver;
import net.lightbody.bmp.proxy.dns.NativeCacheManipulatingResolver;
import net.lightbody.bmp.proxy.dns.NativeResolver;
import org.openqa.selenium.Proxy;
Expand Down Expand Up @@ -44,10 +41,11 @@ public static AdvancedHostResolver createNativeResolver() {
* @return a new DnsJavaResolver
* @deprecated The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BMP >2.1.
*/
/*
public static AdvancedHostResolver createDnsJavaResolver() {
return new DnsJavaResolver();
}

*/
/**
* Creates a {@link net.lightbody.bmp.proxy.dns.ChainedHostResolver} instance that first attempts to resolve a hostname using a
* {@link net.lightbody.bmp.proxy.dns.DnsJavaResolver}, then uses {@link net.lightbody.bmp.proxy.dns.NativeCacheManipulatingResolver}.
Expand All @@ -56,10 +54,11 @@ public static AdvancedHostResolver createDnsJavaResolver() {
* @return a new ChainedHostResolver that resolves addresses first using a DnsJavaResolver, then using a NativeCacheManipulatingResolver
* @deprecated The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BMP >2.1.
*/
/*
public static AdvancedHostResolver createDnsJavaWithNativeFallbackResolver() {
return new ChainedHostResolver(ImmutableList.of(new DnsJavaResolver(), new NativeCacheManipulatingResolver()));
}

*/
/**
* Creates a Selenium Proxy object from the BrowserMobProxy instance. The BrowserMobProxy must be started. Retrieves the address
* of the Proxy using {@link #getConnectableAddress()}.
Expand All @@ -68,6 +67,7 @@ public static AdvancedHostResolver createDnsJavaWithNativeFallbackResolver() {
* @return a Selenium Proxy instance, configured to use the BrowserMobProxy instance as its proxy server
* @throws java.lang.IllegalStateException if the proxy has not been started.
*/

public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserMobProxy browserMobProxy) {
return createSeleniumProxy(browserMobProxy, getConnectableAddress());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaderNames;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
Expand Down Expand Up @@ -126,28 +128,28 @@ protected void captureFullResponseContents() {
}

protected void decompressContents() {
if (contentEncoding.equals(HttpHeaders.Values.GZIP)) {
if (HttpHeaderValues.GZIP.contentEqualsIgnoreCase(contentEncoding)) {
try {
fullResponseContents = BrowserMobHttpUtil.decompressContents(getRawResponseContents());
decompressionSuccessful = true;
} catch (RuntimeException e) {
log.warn("Failed to decompress response with encoding type " + contentEncoding + " when decoding request from " + originalRequest.getUri(), e);
log.warn("Failed to decompress response with encoding type " + contentEncoding + " when decoding request from " + originalRequest.uri(), e);
}
} else {
log.warn("Cannot decode unsupported content encoding type {}", contentEncoding);
}
}

protected void captureContentEncoding(HttpResponse httpResponse) {
contentEncoding = HttpHeaders.getHeader(httpResponse, HttpHeaders.Names.CONTENT_ENCODING);
contentEncoding = httpResponse.headers().get(HttpHeaderNames.CONTENT_ENCODING);
}

protected void captureTrailingHeaders(LastHttpContent lastContent) {
trailingHeaders = lastContent.trailingHeaders();

// technically, the Content-Encoding header can be in a trailing header, although this is excruciatingly uncommon
if (trailingHeaders != null) {
String trailingContentEncoding = trailingHeaders.get(HttpHeaders.Names.CONTENT_ENCODING);
String trailingContentEncoding = trailingHeaders.get(HttpHeaderNames.CONTENT_ENCODING);
if (trailingContentEncoding != null) {
contentEncoding = trailingContentEncoding;
}
Expand Down

This file was deleted.

60 changes: 0 additions & 60 deletions browsermob-dist/assembly.xml

This file was deleted.

Loading

0 comments on commit e7ab019

Please sign in to comment.