Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit 22afbd3

Browse files
initial commit (#15)
* initial commit * promote poms * promote poms * promote poms * revert jetty * One more part done * one moe small change * one more small improvement * Snapshot version promotion * small changes in har * pormote snapshot
1 parent b44c839 commit 22afbd3

File tree

26 files changed

+2135
-1988
lines changed

26 files changed

+2135
-1988
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ When you build the latest code from source, you'll have access to the latest sna
395395
<dependency>
396396
<groupId>net.lightbody.bmp</groupId>
397397
<artifactId>browsermob-core</artifactId>
398-
<version>2.1.20-SNAPSHOT</version>
398+
<version>2.1.22-SNAPSHOT</version>
399399
<scope>test</scope>
400400
</dependency>
401401
```

browsermob-core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
<parent>
77
<artifactId>browsermob-proxy</artifactId>
88
<groupId>net.lightbody.bmp</groupId>
9-
<version>2.1.20-SNAPSHOT</version>
9+
<version>2.1.22-SNAPSHOT</version>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212

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

1616
<properties>
17-
<unit-test-jetty.version>7.6.16.v20140903</unit-test-jetty.version>
17+
<unit-test-jetty.version>9.4.15.v20190215</unit-test-jetty.version>
1818
</properties>
1919

2020
<build>
@@ -42,7 +42,7 @@
4242
<groupId>org.apache.maven.plugins</groupId>
4343
<artifactId>maven-surefire-plugin</artifactId>
4444
<configuration>
45-
<argLine>-Xmx1g -XX:MaxPermSize=256m</argLine>
45+
<argLine>-Xmx1g</argLine>
4646
</configuration>
4747
</plugin>
4848
</plugins>

browsermob-core/src/main/java/net/lightbody/bmp/core/har/HarRequest.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package net.lightbody.bmp.core.har;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import org.apache.commons.lang3.builder.EqualsBuilder;
5+
import org.apache.commons.lang3.builder.HashCodeBuilder;
46

57
import java.util.List;
68
import java.util.concurrent.CopyOnWriteArrayList;
@@ -95,4 +97,41 @@ public void setComment(String comment) {
9597
this.comment = comment;
9698
}
9799

100+
@Override
101+
public boolean equals(Object o) {
102+
if (this == o) return true;
103+
104+
if (o == null || getClass() != o.getClass()) return false;
105+
106+
HarRequest that = (HarRequest) o;
107+
108+
return new EqualsBuilder()
109+
.append(headersSize, that.headersSize)
110+
.append(bodySize, that.bodySize)
111+
.append(method, that.method)
112+
.append(url, that.url)
113+
.append(httpVersion, that.httpVersion)
114+
.append(cookies, that.cookies)
115+
.append(headers, that.headers)
116+
.append(queryString, that.queryString)
117+
.append(postData, that.postData)
118+
.append(comment, that.comment)
119+
.isEquals();
120+
}
121+
122+
@Override
123+
public int hashCode() {
124+
return new HashCodeBuilder(17, 37)
125+
.append(method)
126+
.append(url)
127+
.append(httpVersion)
128+
.append(cookies)
129+
.append(headers)
130+
.append(queryString)
131+
.append(postData)
132+
.append(headersSize)
133+
.append(bodySize)
134+
.append(comment)
135+
.toHashCode();
136+
}
98137
}

browsermob-core/src/main/java/net/lightbody/bmp/filters/AutoBasicAuthFilter.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package net.lightbody.bmp.filters;
22

33
import io.netty.channel.ChannelHandlerContext;
4-
import io.netty.handler.codec.http.HttpHeaders;
5-
import io.netty.handler.codec.http.HttpObject;
6-
import io.netty.handler.codec.http.HttpRequest;
7-
import io.netty.handler.codec.http.HttpResponse;
4+
import io.netty.handler.codec.http.*;
85
import org.littleshoot.proxy.impl.ProxyUtils;
96

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

browsermob-core/src/main/java/net/lightbody/bmp/filters/ClientRequestCaptureFilter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
import io.netty.buffer.ByteBuf;
44
import io.netty.channel.ChannelHandlerContext;
5-
import io.netty.handler.codec.http.HttpContent;
6-
import io.netty.handler.codec.http.HttpHeaders;
7-
import io.netty.handler.codec.http.HttpObject;
8-
import io.netty.handler.codec.http.HttpRequest;
9-
import io.netty.handler.codec.http.HttpResponse;
10-
import io.netty.handler.codec.http.LastHttpContent;
5+
import io.netty.handler.codec.http.*;
116
import net.lightbody.bmp.util.BrowserMobHttpUtil;
127
import org.littleshoot.proxy.HttpFiltersAdapter;
138

@@ -60,7 +55,7 @@ public HttpResponse clientToProxyRequest(HttpObject httpObject) {
6055

6156
if (httpContent instanceof LastHttpContent) {
6257
LastHttpContent lastHttpContent = (LastHttpContent) httpContent;
63-
trailingHeaders = lastHttpContent .trailingHeaders();
58+
trailingHeaders = lastHttpContent.trailingHeaders();
6459
}
6560
}
6661

browsermob-core/src/main/java/net/lightbody/bmp/filters/HarCaptureFilter.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@
1010
import io.netty.handler.codec.http.cookie.ClientCookieDecoder;
1111
import io.netty.handler.codec.http.cookie.Cookie;
1212
import io.netty.handler.codec.http.cookie.ServerCookieDecoder;
13-
import net.lightbody.bmp.core.har.Har;
14-
import net.lightbody.bmp.core.har.HarCookie;
15-
import net.lightbody.bmp.core.har.HarEntry;
16-
import net.lightbody.bmp.core.har.HarNameValuePair;
17-
import net.lightbody.bmp.core.har.HarPostData;
18-
import net.lightbody.bmp.core.har.HarPostDataParam;
19-
import net.lightbody.bmp.core.har.HarRequest;
20-
import net.lightbody.bmp.core.har.HarResponse;
13+
import net.lightbody.bmp.core.har.*;
2114
import net.lightbody.bmp.exception.UnsupportedCharsetException;
2215
import net.lightbody.bmp.filters.support.HttpConnectTiming;
2316
import net.lightbody.bmp.filters.util.HarCaptureUtil;
@@ -33,17 +26,11 @@
3326
import java.net.InetSocketAddress;
3427
import java.nio.charset.Charset;
3528
import java.nio.charset.StandardCharsets;
36-
import java.util.Calendar;
37-
import java.util.Date;
38-
import java.util.EnumSet;
39-
import java.util.List;
40-
import java.util.Map;
41-
import java.util.Set;
29+
import java.util.*;
4230
import java.util.concurrent.TimeUnit;
4331
import java.util.concurrent.atomic.AtomicInteger;
4432

4533
import static net.lightbody.bmp.filters.StatsDMetricsFilter.*;
46-
import static net.lightbody.bmp.filters.StatsDMetricsFilter.getStatsDPort;
4734

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

275262
harEntry.getResponse().setBodySize(responseBodySize.get());
263+
logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());
276264
}
277-
278-
logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());
279-
265+
280266
return super.serverToProxyResponse(httpObject);
281267
}
282268

@@ -307,6 +293,8 @@ else if (sendFinishedNanos > 0L && responseReceiveStartedNanos == 0L) {
307293
else if (responseReceiveStartedNanos > 0L) {
308294
harEntry.getTimings().setReceive(timeoutTimestampNanos - responseReceiveStartedNanos, TimeUnit.NANOSECONDS);
309295
}
296+
297+
logFailedRequestIfRequired(harEntry.getRequest(), harEntry.getResponse());
310298
}
311299

312300
/**

browsermob-core/src/main/java/net/lightbody/bmp/util/BrowserMobHttpUtil.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class BrowserMobHttpUtil {
5151
* Likewise, special treatment of ISO-8859-1 has been removed from the
5252
* Accept-Charset header field.
5353
* </pre>
54-
*
54+
* <p>
5555
* Technically, we would have to determine the charset on a per-content-type basis, but generally speaking, UTF-8 is a
5656
* pretty safe default. (NOTE: In the previous HTTP/1.1 spec, section 3.7.1, the default charset was defined as ISO-8859-1.)
5757
*/
@@ -118,7 +118,7 @@ public static byte[] decompressContents(byte[] fullMessage) throws Decompression
118118
*
119119
* @param fullMessage brotli byte stream to decompress
120120
* @return decompressed bytes
121-
* @throws DecompressionException thrown if the fullMessage cannot be read or decompressed for any reason
121+
* @throws DecompressionException thrown if the fullMessage cannot be read or decompressed for any reason
122122
*/
123123
public static byte[] decompressBrotliContents(byte[] fullMessage) throws DecompressionException {
124124
InputStream brotliReader = null;
@@ -167,11 +167,11 @@ public static byte[] decompressBrotliContents(byte[] fullMessage) throws Decompr
167167
public static boolean hasTextualContent(String contentType) {
168168
return contentType != null &&
169169
(contentType.startsWith("text/") ||
170-
contentType.startsWith("application/x-javascript") ||
171-
contentType.startsWith("application/javascript") ||
172-
contentType.startsWith("application/json") ||
173-
contentType.startsWith("application/xml") ||
174-
contentType.startsWith("application/xhtml+xml")
170+
contentType.startsWith("application/x-javascript") ||
171+
contentType.startsWith("application/javascript") ||
172+
contentType.startsWith("application/json") ||
173+
contentType.startsWith("application/xml") ||
174+
contentType.startsWith("application/xhtml+xml")
175175
);
176176
}
177177

@@ -222,8 +222,8 @@ public static Charset readCharsetInContentTypeHeader(String contentTypeHeader) t
222222

223223
MediaType mediaType;
224224
try {
225-
mediaType = MediaType.parse(contentTypeHeader);
226-
} catch (IllegalArgumentException e) {
225+
mediaType = MediaType.parse(contentTypeHeader);
226+
} catch (java.lang.IllegalArgumentException e) {
227227
log.info("Unable to parse Content-Type header: {}. Content-Type header will be ignored.", contentTypeHeader, e);
228228
return null;
229229
}
@@ -307,7 +307,7 @@ public static boolean isRedirect(HttpResponse httpResponse) {
307307
* parsing the hostname, but makes no guarantees. In general, it should be validated externally, if necessary.
308308
*
309309
* @param hostWithPort string containing a hostname and optional port
310-
* @param portNumber port to remove from the string
310+
* @param portNumber port to remove from the string
311311
* @return string with the specified port removed, or the original string if it did not contain the portNumber
312312
*/
313313
public static String removeMatchingPort(String hostWithPort, int portNumber) {

browsermob-core/src/test/java/net/lightbody/bmp/proxy/dns/ChainedHostResolverTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static org.junit.Assert.assertEquals;
2525
import static org.junit.Assert.assertNotNull;
2626
import static org.junit.Assert.assertTrue;
27-
import static org.mockito.Matchers.any;
27+
import static org.mockito.ArgumentMatchers.any;
2828
import static org.mockito.Mockito.doAnswer;
2929
import static org.mockito.Mockito.mock;
3030
import static org.mockito.Mockito.never;

browsermob-dist/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>browsermob-proxy</artifactId>
66
<groupId>net.lightbody.bmp</groupId>
7-
<version>2.1.20-SNAPSHOT</version>
7+
<version>2.1.22-SNAPSHOT</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

browsermob-legacy/pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<packaging>jar</packaging>
45

56
<parent>
67
<artifactId>browsermob-proxy</artifactId>
78
<groupId>net.lightbody.bmp</groupId>
8-
<version>2.1.20-SNAPSHOT</version>
9+
<version>2.1.22-SNAPSHOT</version>
910
</parent>
1011
<modelVersion>4.0.0</modelVersion>
1112

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

1516
<properties>
16-
<unit-test-jetty.version>7.6.16.v20140903</unit-test-jetty.version>
17+
<unit-test-jetty.version>9.4.15.v20190215</unit-test-jetty.version>
1718
<use.littleproxy>true</use.littleproxy>
1819
</properties>
1920

@@ -23,7 +24,7 @@
2324
<groupId>org.apache.maven.plugins</groupId>
2425
<artifactId>maven-surefire-plugin</artifactId>
2526
<configuration>
26-
<argLine>-Xmx1g -XX:MaxPermSize=256m</argLine>
27+
<argLine>-Xmx1g</argLine>
2728
<systemProperties>
2829
<!-- Execute tests against the LP version unless the legacy profile is explicitly specified. -->
2930
<bmp.use.littleproxy>${use.littleproxy}</bmp.use.littleproxy>
@@ -80,13 +81,13 @@
8081
<dependency>
8182
<groupId>commons-io</groupId>
8283
<artifactId>commons-io</artifactId>
83-
<version>2.5</version>
84+
<version>2.6</version>
8485
</dependency>
8586

8687
<dependency>
8788
<groupId>javax.servlet</groupId>
88-
<artifactId>servlet-api</artifactId>
89-
<version>2.5</version>
89+
<artifactId>javax.servlet-api</artifactId>
90+
<version>4.0.1</version>
9091
</dependency>
9192

9293
<dependency>

0 commit comments

Comments
 (0)