How to manually set upstream proxy for fiddler cor

2020-07-07 11:58发布

问题:

I'd like to be able to redirect http requests from fiddler code through upstream proxys, which I want to be able to specify at runtime.

I've looked through FiddlerApplication functions, and I don't see anything that might fit, as well as I haven't found anything matching in the documentation (except that you might specify a startup flag to use system's proxy as upstream proxy).

What is the best way to specify/change fiddler core proxy at runtime?

回答1:

If you want to send each request to a proxy, and that proxy isn't the system's default: Before each request is sent, specify the X-OverrideGateway flag on the Session. Inside your BeforeRequest handler, add the following line:

oSession["X-OverrideGateway"] = "someProxy:1234";

-Eric



回答2:

As EricLaw have said in his answer that you have to specify X-OverrideGateway flag on the Session, although if you want to do a basic HTTP authentication to the upstream proxy, you can set the credentials by adding the Proxy-Authorization header to the session inside your BeforeRequest handler like that

string userCredentials = string.Format("{0}:{1}", "user", "password");
string base64UserCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(userCredentials));
oSession.RequestHeaders["Proxy-Authorization"] = "Basic " + base64UserCredentials;

Here's a list of the HTTP header fields https://en.wikipedia.org/wiki/List_of_HTTP_header_fields