I already built a Java app that can remove graphics from swf files, but Fiddler isn't stable enough to run it unattended all day. I am looking for advices to build a Fiddler-like Java proxy that can modify incoming responses on the go.
int anyPort = 8080;
ServerSocket serverSocket = new ServerSocket(anyPort);
while (true) {
try (Socket client = serverSocket.accept()) {
Request request = readRequest(client);
if(request.host == "whatever.com" && request.path == "/example")
{
client.sendResponse("My custom response!");
}
else
{
Response response = forwardRequestToRealHost(client, request);
client.sendResponse(response);
}
}
}
I didn't know Socket would do the same job, I already have some experience with sockets to just communicate based on strings, thank you I will give it a try.Quote:
You can quickly write your own implementation. A proxy is just a TCP socket that sits between your browser and the real host.
[REQ]CONNECT whatismyipaddress.com:443 HTTP/1.1 Host: whatismyipaddress.com:443 Proxy-Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 roxy-Connection: Keep-Alive Pragma: no-cache