How to manually set upstream proxy for fiddler core?

▼魔方 西西 提交于 2019-12-05 20:50:15

问题


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



来源:https://stackoverflow.com/questions/14284256/how-to-manually-set-upstream-proxy-for-fiddler-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!