Skip to content

Commit eeaadbe

Browse files
committed
Documentation updates for 2.1.0-beta-1
1 parent 0a3e6ef commit eeaadbe

File tree

1 file changed

+72
-29
lines changed

1 file changed

+72
-29
lines changed

README.md

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,58 @@
22

33
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.
44

5-
Version 2.1 is currently in development, and contains a number of improvements over 2.0. We highly recommend that you use a 2.1 beta 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).
66

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,
12+
change the artifactId to browsermob-core -->
13+
<artifactId>browsermob-core-littleproxy</artifactId>
14+
<version>2.1.0-beta-1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
```
818

9-
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).
1020

1121
## Important Changes since 2.0.0
1222

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:
1424

1525
- [Separate REST API and Embedded Mode modules](#embedded-mode). Include only the functionality you need.
1626
- [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.
1828

1929
See the [New Interface Compatibility Guide](new-interface-compatibility.md) for information on using the new BrowserMobProxy interface with the legacy ProxyServer implementation.
2030

2131
### New BrowserMobProxy API
2232

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.
2434

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.
2636

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
2838

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 = new ProxyServer();
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:
49+
LegacyProxyServer proxyServer = new BrowserMobProxyServer();
50+
proxyServer.start();
51+
// 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.
3057

3158
### LittleProxy Support
3259

@@ -35,7 +62,7 @@ BrowserMob Proxy now supports using LittleProxy instead of Jetty 5 + Apache HTTP
3562
<dependency>
3663
<groupId>net.lightbody.bmp</groupId>
3764
<artifactId>browsermob-core-littleproxy</artifactId>
38-
<version>2.1.0-beta-1-SNAPSHOT</version>
65+
<version>2.1.0-beta-1</version>
3966
<scope>test</scope>
4067
</dependency>
4168
```
@@ -46,6 +73,8 @@ Instead of creating a `ProxyServer` instance, create a `BrowserMobProxyServer` i
4673
proxy.start();
4774
```
4875

76+
To continue using the legacy Jetty-based implementation, include the `browsermob-core` artifact.
77+
4978
## Features and Usage
5079

5180
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.
181210

182211
**New in 2.1:** New [BrowserMobProxy interface](#new-browsermobproxy-api) for Embedded Mode
183212

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`.
185214

186215
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:
187216
```xml
188217
<dependency>
189218
<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 -->
220+
<artifactId>browsermob-core-littleproxy</artifactId>
221+
<version>2.1.0-beta-1</version>
192222
<scope>test</scope>
193223
</dependency>
194224
```
195225

196226
Once done, you can start a proxy using `net.lightbody.bmp.BrowserMobProxy`:
197227
```java
198-
BrowserMobProxy server = new ProxyServer();
199-
server.start(0);
228+
BrowserMobProxy proxy = new BrowserMobProxyServer();
229+
proxy.start(0);
200230
// get the JVM-assigned port and get to work!
201-
int port = server.getPort();
231+
int port = proxy.getPort();
202232
//...
203233

204234
```
@@ -210,11 +240,11 @@ Consult the Javadocs on the `net.lightbody.bmp.BrowserMobProxy` class for the fu
210240
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:
211241
```java
212242
// start the proxy
213-
BrowserMobProxy server = new ProxyServer();
214-
server.start(0);
243+
BrowserMobProxy proxy = new BrowserMobProxyServer();
244+
proxy.start(0);
215245

216246
// get the Selenium proxy object
217-
Proxy proxy = ClientUtil.createSeleniumProxy(server);
247+
Proxy proxy = ClientUtil.createSeleniumProxy(proxy);
218248

219249
// configure it as a desired capability
220250
DesiredCapabilities capabilities = new DesiredCapabilities();
@@ -224,13 +254,13 @@ You can use the REST API with Selenium however you want. But if you're writing y
224254
WebDriver driver = new FirefoxDriver(capabilities);
225255

226256
// create a new HAR with the label "yahoo.com"
227-
server.newHar("yahoo.com");
257+
proxy.newHar("yahoo.com");
228258

229259
// open yahoo.com
230260
driver.get("http://yahoo.com");
231261

232262
// get the HAR data
233-
Har har = server.getHar();
263+
Har har = proxy.getHar();
234264
```
235265

236266
### HTTP Request Manipulation
@@ -251,7 +281,7 @@ For most use cases, including inspecting and modifying requests/responses, `addR
251281
proxy.addRequestFilter(new RequestFilter() {
252282
@Override
253283
public HttpResponse filterRequest(HttpRequest request, HttpMessageContents contents, HttpMessageInfo messageInfo) {
254-
if (request.getUri().equals("/some-endpoint-to-intercept")) {
284+
if (messageInfo.getOriginalUri().endsWith("/some-endpoint-to-intercept")) {
255285
// retrieve the existing message contents as a String or, for binary contents, as a byte[]
256286
String messageContents = contents.getTextContents();
257287

@@ -337,9 +367,11 @@ Consult the Java API docs for more info.
337367

338368
### SSL Support
339369

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.
341371

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.
343375

344376
### NodeJS Support
345377

@@ -349,7 +381,7 @@ NodeJS bindings for browswermob-proxy are available [here](https://github.com/zz
349381

350382
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.
351383

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`.
353385

354386
### DNS Resolution
355387

@@ -369,7 +401,7 @@ or in Windows:
369401
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:
370402

371403
```java
372-
BrowserMobProxy proxyServer = new ProxyServer();
404+
BrowserMobProxy proxyServer = new BrowserMobProxyServer();
373405
// use only dnsjava
374406
proxyServer.setHostNameResolver(ClientUtil.createDnsJavaResolver());
375407
// or use only native resolution
@@ -378,9 +410,20 @@ If you are running in Embedded Mode (for example, within a Selenium test) you ca
378410
proxyServer.start(0);
379411
```
380412

381-
## Creating the batch files from source
413+
## Building the latest from source
382414

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.
384416

385-
[~]$ mvn -P release
386417
[~]$ 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:
422+
```xml
423+
<dependency>
424+
<groupId>net.lightbody.bmp</groupId>
425+
<artifactId>browsermob-core-littleproxy</artifactId>
426+
<version>2.1.0-beta-2-SNAPSHOT</version>
427+
<scope>test</scope>
428+
</dependency>
429+
```

0 commit comments

Comments
 (0)