LittleProxy is a high performance HTTP proxy written in Java atop Trustin Lee's excellent Netty event-based networking library. It's quite stable, performs well, and is easy to integrate into your projects.
One option is to clone LittleProxy and run it from the command line. This is as simple as:
$ git clone git://github.com/adamfisk/LittleProxy.git
$ cd LittleProxy
$ ./run.bash
You can embed LittleProxy in your own projects through maven with the following:
<dependency>
<groupId>org.littleshoot</groupId>
<artifactId>littleproxy</artifactId>
<version>1.0.0-beta3</version>
</dependency>
Once you've included LittleProxy, you can start the server with the following:
HttpProxyServer server =
DefaultHttpProxyServer.bootstrap()
.withPort(8080)
.start();
There are lots of filters and such you can also add to LittleProxy. You can add
request and response filters using an HttpFiltersSource(Adapter)
, for example:
HttpProxyServer server =
DefaultHttpProxyServer.bootstrap()
.withPort(8080)
.withFiltersSource(new HttpFiltersSourceAdapter() {
public HttpFilters filterRequest(HttpRequest originalRequest) {
// Check the originalRequest to see if we want to filter it
boolean wantToFilterRequest = ...;
if (!wantToFilterRequest) {
return null;
} else {
return new HttpFiltersAdapter(originalRequest) {
@Override
public HttpResponse requestPre(HttpObject httpObject) {
// TODO: implement your filtering here
return null;
}
@Override
public HttpResponse requestPost(HttpObject httpObject) {
// TODO: implement your filtering here
return null;
}
@Override
public void responsePre(HttpObject httpObject) {
// TODO: implement your filtering here
}
@Override
public void responsePost(HttpObject httpObject) {
// TODO: implement your filtering here
}
};
}
}
})
.start();
If you want to create additional proxy servers with similar configuration but listening on different ports, you can clone an existing server. The cloned servers will share event loops to reduce resource usage and when one clone is stopped, all are stopped.
existingServer.clone().withPort(8081).start()
If you have questions, please visit our Google Group here:
https://groups.google.com/forum/#!forum/littleproxy
Project reports, including the [API Documentation] (http://littleproxy.org/apidocs/index.html), can be found here:
Benchmarking instructions and results can be found here.
Many thanks to The Measurement Factory for the use of Co-Advisor for HTTP standards compliance testing.
- #96 If idleConnectionTimeout is exceeded no response is returned
- #98 Turn down log level on errors/warnings about which nothing can be done
- #106 UDT binding reverses local and remote addresses
This release added back basic support for Man in the Middle (MITM) proxying. The current MITM support is intended primarily for projects that wish to use LittleProxy to facilitate HTTP related testing. See MitmProxyTest for an example of how to use the updated MITM support.
Certificate impersonation would need to be implemented in order for LittleProxy to work well in an end-user facing capacity. This release includes the hooks for doing so, through the new MitmManager abstraction.
- #79 Add back Man in the Middle Support
- #88 Issue with HTTP 301/302 with MITM
- #90 HTTPS requests without host:port get assigned to a different connection than the one opened with the initial CONNECT
- #91 Allow chained proxies to not do client authentication if they don't want to
- #92 MITM proxying to hosts whose names begin with "http" is broken
- #93 Filters on reused ProxyToServerConnections still reference the first HttpRequest that opened the connection
This release switched LittleProxy from Netty 3 to Netty 4. As part of the upgrade, LittleProxy's public API and internal implementation were significantly refactored for maintainability and API stability.
Support for Man in the Middle proxying was temporarily dropped in this release.