Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Added request param as captureRequestContent in HAR #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -103,7 +103,7 @@ Description | HTTP method | Request path | Request parameters
--- | :---: | :---: | ---
Get a list of ports attached to `ProxyServer` instances managed by `ProxyManager` | GET | */proxy* ||
Creates a new proxy to run requests off of | POST | */proxy* | <p>*port* - Integer, The specific port to start the proxy service on. Optional, default is generated and returned in response.</p><p>*proxyUsername* - String, The username to use to authenticate with the chained proxy. Optional, default to null.</p><p>*proxyPassword* - String, The password to use to authenticate with the chained proxy. Optional, default to null.</p><p>*bindAddress* - String, If running BrowserUp Proxy in a multi-homed environment, specify a desired bind address. Optional, default to "0.0.0.0".</p><p>*serverBindAddress* - String, If running BrowserUp Proxy in a multi-homed environment, specify a desired server bind address. Optional, default to "0.0.0.0".</p><p>*useEcc* - Boolean. True, Uses Elliptic Curve Cryptography for certificate impersonation. Optional, default to "false".</p><p>*trustAllServers* - Boolean. True, Disables verification of all upstream servers' SSL certificates. All upstream servers will be trusted, even if they do not present valid certificates signed by certification authorities in the JDK's trust store. Optional, default to "false".</p>|
<a name="harcreate">Creates a new HAR</a> attached to the proxy and returns the HAR content if there was a previous HAR. *[port]* in request path it is port where your proxy was started | PUT |*/proxy/[port]/har* |<p>*captureHeaders* - Boolean, capture headers or not. Optional, default to "false".</p><p>*captureCookies* - Boolean, capture cookies or not. Optional, default to "false".</p><p>*captureContent* - Boolean, capture content bodies or not. Optional, default to "false".</p><p>*captureBinaryContent* - Boolean, capture binary content or not. Optional, default to "false".</p><p>*initialPageRef* - The string name of The first page ref that should be used in the HAR. Optional, default to "Page 1".</p><p>*initialPageTitle* - The title of first HAR page. Optional, default to *initialPageRef*.</p>
<a name="harcreate">Creates a new HAR</a> attached to the proxy and returns the HAR content if there was a previous HAR. *[port]* in request path it is port where your proxy was started | PUT |*/proxy/[port]/har* |<p>*captureHeaders* - Boolean, capture headers or not. Optional, default to "false".</p><p>*captureCookies* - Boolean, capture cookies or not. Optional, default to "false".</p><p>*captureRequestContent* - Boolean, capture only request content body or not. Optional, default to "false".</p><p>*captureContent* - Boolean, capture content bodies or not. Optional, default to "false".</p><p>*captureBinaryContent* - Boolean, capture binary content or not. Optional, default to "false".</p><p>*initialPageRef* - The string name of The first page ref that should be used in the HAR. Optional, default to "Page 1".</p><p>*initialPageTitle* - The title of first HAR page. Optional, default to *initialPageRef*.</p>
Starts a new page on the existing HAR. *[port]* in request path it is port where your proxy was started | PUT | */proxy/[port]/har/pageRef* |<p>*pageRef* - The string name of the first page ref that should be used in the HAR. Optional, default to "Page N" where N is the next page number.</p><p>*pageTitle* - The title of new HAR page. Optional, default to `pageRef`.</p>
Shuts down the proxy and closes the port. *[port]* in request path it is port where your proxy was started | DELETE | */proxy/[port]* ||
Returns the JSON/HAR content representing all the HTTP traffic passed through the proxy (provided you have already created the HAR with [this method](#harcreate)) | GET | */proxy/[port]/har* ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,26 @@ public Reply<?> getHar(@Named("port") int port, Request request) {
public Reply<?> newHar(@Named("port") int port, Request request) {
LOG.info("PUT /" + port + "/har");
LOG.info(request.params().toString());
MitmProxyServer proxy = proxyManager.get(port);
final MitmProxyServer proxy = proxyManager.get(port);
if (proxy == null) {
return Reply.saying().notFound();
}

String initialPageRef = request.param("initialPageRef");
String initialPageTitle = request.param("initialPageTitle");
Har oldHar = proxy.newHar(initialPageRef, initialPageTitle);
final String initialPageRef = request.param("initialPageRef");
final String initialPageTitle = request.param("initialPageTitle");
final Har oldHar = proxy.newHar(initialPageRef, initialPageTitle);

String captureHeaders = request.param("captureHeaders");
String captureContent = request.param("captureContent");
String captureBinaryContent = request.param("captureBinaryContent");
Set<CaptureType> captureTypes = new HashSet<CaptureType>();
final String captureHeaders = request.param("captureHeaders");
final String captureRequestContent = request.param("captureRequestContent");
final String captureContent = request.param("captureContent");
final String captureBinaryContent = request.param("captureBinaryContent");
final Set<CaptureType> captureTypes = new HashSet<CaptureType>();
if (Boolean.parseBoolean(captureHeaders)) {
captureTypes.addAll(CaptureType.getHeaderCaptureTypes());
}
if(Boolean.parseBoolean(captureRequestContent)){
captureTypes.addAll(CaptureType.getRequestCaptureTypes());
}
if (Boolean.parseBoolean(captureContent)) {
captureTypes.addAll(CaptureType.getAllContentCaptureTypes());
}
Expand All @@ -187,9 +191,9 @@ public Reply<?> newHar(@Named("port") int port, Request request) {
}
proxy.setHarCaptureTypes(captureTypes);

String captureCookies = request.param("captureCookies");
final String captureCookies = request.param("captureCookies");
if (proxy instanceof MitmProxyServer && Boolean.parseBoolean(captureCookies)) {
MitmProxyServer MitmProxyServer = (MitmProxyServer) proxy;
final MitmProxyServer MitmProxyServer = (MitmProxyServer) proxy;
MitmProxyServer.enableHarCaptureTypes(CaptureType.getCookieCaptureTypes());
}

Expand Down