Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit d04117b

Browse files
committed
enable/disable direct resolution on an instantiated proxy
1 parent 5bd2f52 commit d04117b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

browsermob-core/src/main/java/net/lightbody/bmp/BrowserMobProxyServer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,12 @@ public InetAddress getServerBindAddress() {
450450
return serverBindAddress;
451451
}
452452

453+
public void setIsDirectResolutionEnabled(boolean useDirect) {
454+
if (proxyServer instanceof DefaultHttpProxyServer) {
455+
((DefaultHttpProxyServer)proxyServer).setIsDirectResolutionEnabled(useDirect);
456+
}
457+
}
458+
453459
@Override
454460
public Har getHar() {
455461
return har;

browsermob-rest/src/main/java/net/lightbody/bmp/proxy/bricks/ProxyResource.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,25 @@ public Reply<?> newProxy(Request<String> request) {
128128
return Reply.with(new ProxyDescriptor(proxy.getPort())).as(Json.class);
129129
}
130130

131+
@Put
132+
@At("/:port/direct")
133+
public Reply<?> setDirect(@Named("port") int port, Request<String> request) {
134+
LegacyProxyServer proxy = proxyManager.get(port);
135+
if (proxy == null) {
136+
return Reply.saying().notFound();
137+
}
138+
139+
String useDirectString = request.param("direct");
140+
boolean useDirect = Boolean.parseBoolean(useDirectString);
141+
System.out.println("Chase -> useDirect is " + useDirect);
142+
143+
if (proxy instanceof BrowserMobProxyServer) {
144+
((BrowserMobProxyServer)proxy).setIsDirectResolutionEnabled(useDirect);
145+
}
146+
147+
return Reply.saying().ok();
148+
}
149+
131150
@Get
132151
@At("/:port/har")
133152
public Reply<?> getHar(@Named("port") int port) {

0 commit comments

Comments
 (0)