Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ When you build the latest code from source, you'll have access to the latest sna
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
<version>2.1.20-SNAPSHOT</version>
<version>2.1.22-SNAPSHOT</version>
<scope>test</scope>
</dependency>
```
6 changes: 3 additions & 3 deletions browsermob-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<parent>
<artifactId>browsermob-proxy</artifactId>
<groupId>net.lightbody.bmp</groupId>
<version>2.1.20-SNAPSHOT</version>
<version>2.1.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>browsermob-core</artifactId>
<name>BrowserMob Proxy Core (LittleProxy) Module</name>

<properties>
<unit-test-jetty.version>7.6.16.v20140903</unit-test-jetty.version>
<unit-test-jetty.version>9.4.15.v20190215</unit-test-jetty.version>
</properties>

<build>
Expand Down Expand Up @@ -42,7 +42,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1g -XX:MaxPermSize=256m</argLine>
<argLine>-Xmx1g</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.lightbody.bmp.core.har;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -95,4 +97,41 @@ public void setComment(String comment) {
this.comment = comment;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;

if (o == null || getClass() != o.getClass()) return false;

HarRequest that = (HarRequest) o;

return new EqualsBuilder()
.append(headersSize, that.headersSize)
.append(bodySize, that.bodySize)
.append(method, that.method)
.append(url, that.url)
.append(httpVersion, that.httpVersion)
.append(cookies, that.cookies)
.append(headers, that.headers)
.append(queryString, that.queryString)
.append(postData, that.postData)
.append(comment, that.comment)
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(method)
.append(url)
.append(httpVersion)
.append(cookies)
.append(headers)
.append(queryString)
.append(postData)
.append(headersSize)
.append(bodySize)
.append(comment)
.toHashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package net.lightbody.bmp.filters;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.*;
import org.littleshoot.proxy.impl.ProxyUtils;

import java.util.Map;
Expand Down Expand Up @@ -45,7 +42,7 @@ public HttpResponse clientToProxyRequest(HttpObject httpObject) {
// if there is an entry in the credentials map matching this hostname, add the credentials to the request
String base64CredentialsForHostname = credentialsByHostname.get(hostname);
if (base64CredentialsForHostname != null) {
httpRequest.headers().add(HttpHeaders.Names.AUTHORIZATION, "Basic " + base64CredentialsForHostname);
httpRequest.headers().add(HttpHeaderNames.AUTHORIZATION, "Basic " + base64CredentialsForHostname);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.codec.http.*;
import net.lightbody.bmp.util.BrowserMobHttpUtil;
import org.littleshoot.proxy.HttpFiltersAdapter;

Expand Down Expand Up @@ -60,7 +55,7 @@ public HttpResponse clientToProxyRequest(HttpObject httpObject) {

if (httpContent instanceof LastHttpContent) {
LastHttpContent lastHttpContent = (LastHttpContent) httpContent;
trailingHeaders = lastHttpContent .trailingHeaders();
trailingHeaders = lastHttpContent.trailingHeaders();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@
import io.netty.handler.codec.http.cookie.ClientCookieDecoder;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
import net.lightbody.bmp.core.har.Har;
import net.lightbody.bmp.core.har.HarCookie;
import net.lightbody.bmp.core.har.HarEntry;
import net.lightbody.bmp.core.har.HarNameValuePair;
import net.lightbody.bmp.core.har.HarPostData;
import net.lightbody.bmp.core.har.HarPostDataParam;
import net.lightbody.bmp.core.har.HarRequest;
import net.lightbody.bmp.core.har.HarResponse;
import net.lightbody.bmp.core.har.*;
import net.lightbody.bmp.exception.UnsupportedCharsetException;
import net.lightbody.bmp.filters.support.HttpConnectTiming;
import net.lightbody.bmp.filters.util.HarCaptureUtil;
Expand All @@ -33,17 +26,11 @@
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import static net.lightbody.bmp.filters.StatsDMetricsFilter.*;
import static net.lightbody.bmp.filters.StatsDMetricsFilter.getStatsDPort;

public class HarCaptureFilter extends HttpsAwareFiltersAdapter {
private static final Logger log = LoggerFactory.getLogger(HarCaptureFilter.class);
Expand Down Expand Up @@ -273,10 +260,9 @@ public HttpObject serverToProxyResponse(HttpObject httpObject) {
}

harEntry.getResponse().setBodySize(responseBodySize.get());
logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());
}

logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());


return super.serverToProxyResponse(httpObject);
}

Expand Down Expand Up @@ -307,6 +293,8 @@ else if (sendFinishedNanos > 0L && responseReceiveStartedNanos == 0L) {
else if (responseReceiveStartedNanos > 0L) {
harEntry.getTimings().setReceive(timeoutTimestampNanos - responseReceiveStartedNanos, TimeUnit.NANOSECONDS);
}

logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BrowserMobHttpUtil {
* Likewise, special treatment of ISO-8859-1 has been removed from the
* Accept-Charset header field.
* </pre>
*
* <p>
* Technically, we would have to determine the charset on a per-content-type basis, but generally speaking, UTF-8 is a
* pretty safe default. (NOTE: In the previous HTTP/1.1 spec, section 3.7.1, the default charset was defined as ISO-8859-1.)
*/
Expand Down Expand Up @@ -118,7 +118,7 @@ public static byte[] decompressContents(byte[] fullMessage) throws Decompression
*
* @param fullMessage brotli byte stream to decompress
* @return decompressed bytes
* @throws DecompressionException thrown if the fullMessage cannot be read or decompressed for any reason
* @throws DecompressionException thrown if the fullMessage cannot be read or decompressed for any reason
*/
public static byte[] decompressBrotliContents(byte[] fullMessage) throws DecompressionException {
InputStream brotliReader = null;
Expand Down Expand Up @@ -167,11 +167,11 @@ public static byte[] decompressBrotliContents(byte[] fullMessage) throws Decompr
public static boolean hasTextualContent(String contentType) {
return contentType != null &&
(contentType.startsWith("text/") ||
contentType.startsWith("application/x-javascript") ||
contentType.startsWith("application/javascript") ||
contentType.startsWith("application/json") ||
contentType.startsWith("application/xml") ||
contentType.startsWith("application/xhtml+xml")
contentType.startsWith("application/x-javascript") ||
contentType.startsWith("application/javascript") ||
contentType.startsWith("application/json") ||
contentType.startsWith("application/xml") ||
contentType.startsWith("application/xhtml+xml")
);
}

Expand Down Expand Up @@ -222,8 +222,8 @@ public static Charset readCharsetInContentTypeHeader(String contentTypeHeader) t

MediaType mediaType;
try {
mediaType = MediaType.parse(contentTypeHeader);
} catch (IllegalArgumentException e) {
mediaType = MediaType.parse(contentTypeHeader);
} catch (java.lang.IllegalArgumentException e) {
log.info("Unable to parse Content-Type header: {}. Content-Type header will be ignored.", contentTypeHeader, e);
return null;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public static boolean isRedirect(HttpResponse httpResponse) {
* parsing the hostname, but makes no guarantees. In general, it should be validated externally, if necessary.
*
* @param hostWithPort string containing a hostname and optional port
* @param portNumber port to remove from the string
* @param portNumber port to remove from the string
* @return string with the specified port removed, or the original string if it did not contain the portNumber
*/
public static String removeMatchingPort(String hostWithPort, int portNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down
2 changes: 1 addition & 1 deletion browsermob-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>browsermob-proxy</artifactId>
<groupId>net.lightbody.bmp</groupId>
<version>2.1.20-SNAPSHOT</version>
<version>2.1.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
15 changes: 8 additions & 7 deletions browsermob-legacy/pom.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<packaging>jar</packaging>

<parent>
<artifactId>browsermob-proxy</artifactId>
<groupId>net.lightbody.bmp</groupId>
<version>2.1.20-SNAPSHOT</version>
<version>2.1.22-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>browsermob-legacy</artifactId>
<name>BrowserMob Proxy Legacy (Jetty) Module</name>

<properties>
<unit-test-jetty.version>7.6.16.v20140903</unit-test-jetty.version>
<unit-test-jetty.version>9.4.15.v20190215</unit-test-jetty.version>
<use.littleproxy>true</use.littleproxy>
</properties>

Expand All @@ -23,7 +24,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1g -XX:MaxPermSize=256m</argLine>
<argLine>-Xmx1g</argLine>
<systemProperties>
<!-- Execute tests against the LP version unless the legacy profile is explicitly specified. -->
<bmp.use.littleproxy>${use.littleproxy}</bmp.use.littleproxy>
Expand Down Expand Up @@ -80,13 +81,13 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<version>2.6</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ public enum SSLAlgorithm {
private StreamManager streamManager;

static {
sslContext = SSLContexts.createDefault();
sslContext = org.apache.http.ssl.SSLContexts.createDefault();
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null,
new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}
).build();
sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null,
(TrustStrategy) (chain, authType) -> true
).build();

sslContext.init(null, new TrustManager[]{new TrustEverythingSSLTrustManager()}, null);
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
Expand Down
Loading