#2310 Using a Proxy with a WebClient (For Fiddler)

Jeremy Criquet Mon 7 Jul 2014

I'm trying to monitor my web requests and responses in Fiddler to get more accurate control of my exact web requests with WebClient. With Java, you can do something like this:

System.setProperty( "http.proxyHost", "127.0.0.1" )
System.setProperty( "https.proxyHost", "127.0.0.1" )
System.setProperty( "http.proxyPort", "8888" )
System.setProperty( "https.proxyPort", "8888" )

I tried putting at the top of my code:

using [java] java.lang::System

But it didn't make this work. It could be that I'm not doing this in a static init method though, as I am used to doing in Java. Does anyone have any tips or know if this is even possible?

http://docs.telerik.com/fiddler/configure-fiddler/tasks/configurejavaapp

SlimerDude Tue 8 Jul 2014

I've not used Fiddler, but you can have static blocks in Fantom:

using [java] java.lang::System

class SysTest {
   
  static {
    System.setProperty("wot", "ever" )      
  }
   
  Void main() {
    echo(System.getProperty("wot"))  // --> ever
    echo(Env.cur.vars["wot"])        // --> null
  }
}

The above system property gets set before the main() method is called and prints out ever. (Note that Env.cur.vars is not so dynamic and doesn't pick up changes to system properties.)

I guess, as you mention, you just need to stick the static block somewhere that gets executed before Fiddler starts.

Or you could set the system properties when you start your Fantom app with Java. Example, in windows:

java -cp %FAN_HOME%\lib\java\sys.jar -Dwot=ever fanx.tools.Fan myPod::myClass

Login or Signup to reply.