You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72-29Lines changed: 72 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -2,31 +2,58 @@
2
2
3
3
BrowserMob Proxy is a simple utility that makes it easy to capture performance data from browsers, typically written using automation toolkits such as Selenium and Watir.
4
4
5
-
Version 2.1is currently in development, and contains a number of improvements over 2.0. We highly recommend that you use a 2.1beta version instead of the previous 2.0.0 release.
5
+
The latest version of BrowserMobProxy is 2.1.0-beta-1. It is the first release that supports the [new BrowserMobProxy interface](#new-browsermobproxy-api), and the first release [powered by LittleProxy](#littleproxy-support). We highly recommend that you use 2.1.0-beta-1 instead of the [previous 2.0.0 release](https://github.com/lightbody/browsermob-proxy/tree/2.0).
6
6
7
-
To build the current development version, see the [build instructions](https://github.com/lightbody/browsermob-proxy#creating-the-batch-files-from-source).
7
+
To use BrowserMob Proxy in your tests, add the `browsermob-core-littleproxy` dependency to your pom:
8
+
```xml
9
+
<dependency>
10
+
<groupId>net.lightbody.bmp</groupId>
11
+
<!-- To use the legacy, Jetty-based implementation,
The previous version of BrowserMob Proxy is 2.0.0 -- see the [2.0.x README](https://github.com/lightbody/browsermob-proxy/tree/2.0) for usage information.
19
+
To run in standalone mode from the command line, download the latest release from the [releases page](https://github.com/lightbody/browsermob-proxy/releases), or [build the latest from source](#building-the-latest-from-source).
10
20
11
21
## Important Changes since 2.0.0
12
22
13
-
Since the 2.1 release is still in beta, some features and functionality (including the BrowserMobProxy interface) may change, although the new interface is largely stable. The most important changes are:
23
+
Since the 2.1 release is still in beta, some features and functionality (including the BrowserMobProxy interface) may change, although the new interface is largely stable. The most important changes from 2.0 are:
14
24
15
25
-[Separate REST API and Embedded Mode modules](#embedded-mode). Include only the functionality you need.
16
26
-[New BrowserMobProxy interface](https://github.com/lightbody/browsermob-proxy/blob/master/browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxy.java). The new interface will completely replace the legacy 2.0 ProxyServer contract in version 3.0 and higher.
17
-
-[LittleProxy support](#littleproxy-support). More powerful than the legacy Jetty back-end. For 2.1 releases, LittleProxy support will be provided through the browsermob-core-littleproxy module.
27
+
-[LittleProxy support](#littleproxy-support). More powerful than the legacy Jetty back-end. For 2.1 releases, LittleProxy support will be provided through the `browsermob-core-littleproxy` module.
18
28
19
29
See the [New Interface Compatibility Guide](new-interface-compatibility.md) for information on using the new BrowserMobProxy interface with the legacy ProxyServer implementation.
20
30
21
31
### New BrowserMobProxy API
22
32
23
-
BrowserMob Proxy 2.1 includes a [new BrowserMobProxy interface](https://github.com/lightbody/browsermob-proxy/blob/master/browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxy.java) to interact with BrowserMob Proxy programmatically. The new interface defines the functionality that BrowserMob Proxy will support in future releases (including 3.0+).
33
+
BrowserMob Proxy 2.1 includes a [new BrowserMobProxy interface](https://github.com/lightbody/browsermob-proxy/blob/master/browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxy.java) to interact with BrowserMob Proxy programmatically. The new interface defines the functionality that BrowserMob Proxy will support in future releases (including 3.0+). Both the legacy (Jetty-based) ProxyServer class and the new, LittleProxy-powered BrowserMobProxy class support the new BrowserMobProxy interface.
24
34
25
-
### Deprecated LegacyProxyServer Interface
35
+
To ease the upgrade path to 3.0 and beyond, we _highly_ recommend using the BrowserMobProxy interface, even if you continue to use the legacy ProxyServer implementation.
26
36
27
-
The legacy interface, implicitly defined by the ProxyServer class, has been extracted into `net.lightbody.bmp.proxy.LegacyProxyServer` and is now officially deprecated. The existing ProxyServer implementation will continue to implement the LegacyProxyServer interface, and the new LittleProxy-based implementation will also implement LegacyProxyServer for all 2.1.x releases. LegacyProxyServer will not be supported after 3.0 is released.
37
+
### Using the LittleProxy implementation with existing code
28
38
29
-
**All users are highly encouraged to use the `net.lightbody.bmp.BrowserMobProxy` interface for all new code.** The new interface provides additional functionality and is compatible with both the legacy Jetty-based ProxyServer implementation [(with some exceptions)](new-interface-compatibility.md) and the new LittleProxy implementation. Using the new interface will greatly increase the likelihood of a smooth transition to 3.0, when the legacy ProxyServer implementation will not be supported.
39
+
The legacy interface, implicitly defined by the ProxyServer class, has been extracted into `net.lightbody.bmp.proxy.LegacyProxyServer` and is now officially deprecated. The new LittleProxy-based implementation will implement LegacyProxyServer for all 2.1.x releases. This means you can switch to the LittleProxy-powered implementation with minimal change to existing code ([with the exception of interceptors](#http-request-manipulation)):
40
+
41
+
```java
42
+
// With the Jetty-based 2.0.0 release, BMP was created like this:
43
+
ProxyServer proxyServer =newProxyServer();
44
+
proxyServer.start();
45
+
// [...]
46
+
47
+
// To use the LittleProxy-powered 2.1.0 release, simply change to
48
+
// the LegacyProxyServer interface and the new LittleProxy-based implementation:
// Almost all deprecated 2.0.0 methods are supported by the
52
+
// new BrowserMobProxyServer implementation, so in most cases,
53
+
// no further code changes are necessary
54
+
```
55
+
56
+
LegacyProxyServer will not be supported after 3.0 is released, so we recommend migrating to the `BrowserMobProxy` interface as soon as possible. The new interface provides additional functionality and is compatible with both the legacy Jetty-based ProxyServer implementation [(with some exceptions)](new-interface-compatibility.md) and the new LittleProxy implementation.
30
57
31
58
### LittleProxy Support
32
59
@@ -35,7 +62,7 @@ BrowserMob Proxy now supports using LittleProxy instead of Jetty 5 + Apache HTTP
@@ -46,6 +73,8 @@ Instead of creating a `ProxyServer` instance, create a `BrowserMobProxyServer` i
46
73
proxy.start();
47
74
```
48
75
76
+
To continue using the legacy Jetty-based implementation, include the `browsermob-core` artifact.
77
+
49
78
## Features and Usage
50
79
51
80
The proxy is programmatically controlled via a REST interface or by being embedded directly inside Java-based programs and unit tests. It captures performance data in the [HAR format](http://groups.google.com/group/http-archive-specification). In addition it can actually control HTTP traffic, such as:
@@ -181,24 +210,25 @@ system properties will be used to specify the upstream proxy.
181
210
182
211
**New in 2.1:** New [BrowserMobProxy interface](#new-browsermobproxy-api) for Embedded Mode
183
212
184
-
BrowserMob Proxy 2.1 separates the Embedded Mode and REST API into two modules. If you only need Embedded Mode functionality, add the `browsermob-core` artifact (or `browsermob-core.jar` file) as a dependency. The REST API artifact is `browsermob-rest`.
213
+
BrowserMob Proxy 2.1 separates the Embedded Mode and REST API into two modules. If you only need Embedded Mode functionality, add the `browsermob-core-littleproxy` artifact as a dependency. The REST API artifact is `browsermob-rest`.
185
214
186
215
If you're using Java and Selenium, the easiest way to get started is to embed the project directly in your test. First, you'll need to make sure that all the dependencies are imported in to the project. You can find them in the *lib* directory. Or, if you're using Maven, you can add this to your pom:
187
216
```xml
188
217
<dependency>
189
218
<groupId>net.lightbody.bmp</groupId>
190
-
<artifactId>browsermob-core</artifactId>
191
-
<version>2.1.0-beta-1-SNAPSHOT</version>
219
+
<!-- To use the legacy, Jetty-based implementation, change the artifactId to browsermob-core -->
Once done, you can start a proxy using `net.lightbody.bmp.BrowserMobProxy`:
197
227
```java
198
-
BrowserMobProxyserver=newProxyServer();
199
-
server.start(0);
228
+
BrowserMobProxyproxy=newBrowserMobProxyServer();
229
+
proxy.start(0);
200
230
// get the JVM-assigned port and get to work!
201
-
int port =server.getPort();
231
+
int port =proxy.getPort();
202
232
//...
203
233
204
234
```
@@ -210,11 +240,11 @@ Consult the Javadocs on the `net.lightbody.bmp.BrowserMobProxy` class for the fu
210
240
You can use the REST API with Selenium however you want. But if you're writing your tests in Java and using Selenium 2, this is the easiest way to use it:
@@ -337,9 +367,11 @@ Consult the Java API docs for more info.
337
367
338
368
### SSL Support
339
369
340
-
While the proxy supports SSL, it requires that a Certificate Authority be installed in to the browser. This allows the browser to trust all the SSL traffic coming from the proxy, which will be proxied using a classic man-in-the-middle technique. IT IS CRITICAL THAT YOU NOT INSTALL THIS CERTIFICATE AUTHORITY ON A BROWSER THAT IS USED FOR ANYTHING OTHER THAN TESTING.
370
+
**LittleProxy support for MITM:** In the current beta release, the `browsermob-core-littleproxy` module supports MITM but does not support dynamic certificate spoofing. In most cases this will not affect your tests, but browsers accessing HTTPS websites through BrowserMob Proxy will be notified that the certificates cannot be verified.
341
371
342
-
If you're doing testing with Selenium, you'll want to make sure that the browser profile that gets set up by Selenium not only has the proxy configured, but also has the CA installed (Firefox set up by Selenium has installed CA by default). Unfortuantely, there is no API for doing this in Selenium, so you'll have to solve it uniquely for each browser type. We hope to make this easier in upcoming releases.
372
+
**Legacy Jetty-based support for MITM:** The legacy `ProxyServer` implementation using the `browsermob-core` module supports MITM and dynamic certificate spoofing. To avoid browser certificate warnings, a Certificate Authority must be installed in the browser. This allows the browser to trust all the SSL traffic coming from the proxy, which will be proxied using a classic man-in-the1-middle technique. IT IS CRITICAL THAT YOU NOT INSTALL THIS CERTIFICATE AUTHORITY ON A BROWSER THAT IS USED FOR ANYTHING OTHER THAN TESTING.
373
+
374
+
If you're doing testing with Selenium, you'll want to make sure that the browser profile that gets set up by Selenium not only has the proxy configured, but also has the CA installed. Unfortuantely, there is no API for doing this in Selenium, so you'll have to solve it uniquely for each browser type. We hope to make this easier in upcoming releases.
343
375
344
376
### NodeJS Support
345
377
@@ -349,7 +381,7 @@ NodeJS bindings for browswermob-proxy are available [here](https://github.com/zz
349
381
350
382
When running in stand-alone mode, the proxy loads the default logging configuration from the conf/bmp-logging.yaml file. To increase/decrease the logging level, change the logging entry for net.lightbody.bmp.
351
383
352
-
**New in 2.1:** Neither Embedded Mode nor the REST API include an slf4j static binding, so you no longer need to exclude the slf4j-jdk14 dependency when including `browsermob-core` or `browsermob-rest`.
384
+
**New in 2.1:** Neither Embedded Mode nor the REST API include an slf4j static binding, so you no longer need to exclude the slf4j-jdk14 dependency when including `browsermob-core`, `browsermob-core-littleproxy` or `browsermob-rest`.
353
385
354
386
### DNS Resolution
355
387
@@ -369,7 +401,7 @@ or in Windows:
369
401
If you are running in Embedded Mode (for example, within a Selenium test) you can disable native fallback or dnsjava by setting the implementation directly:
@@ -378,9 +410,20 @@ If you are running in Embedded Mode (for example, within a Selenium test) you ca
378
410
proxyServer.start(0);
379
411
```
380
412
381
-
## Creating the batch files from source
413
+
## Building the latest from source
382
414
383
-
You'll need maven (`brew install maven` if you're on OS X); use the `release` profile to generate the batch files from this repository. Optionally, proceed at your own risk and append the `-DskipTests` option if the tests are failing.
415
+
You'll need maven (`brew install maven` if you're on OS X); use the `release` profile to generate the batch files from this repository.
384
416
385
-
[~]$ mvn -P release
386
417
[~]$ mvn -DskipTests -P release
418
+
419
+
You'll find the standalone BrowserMob Proxy distributable zip at `browsermob-dist/target/browsermob-proxy-2.1.0-beta-2-SNAPSHOT-bin.zip`. Unzip the contents and run the `browsermob-proxy` or `browsermob-proxy.bat` files in the `bin` directory.
420
+
421
+
When you build the latest code from source, you'll have access to the latest snapshot release. To use the SNAPSHOT version in your code, modify the version in your pom:
0 commit comments