How to make a lightweight transparent http proxy t

2019-09-13 18:50发布

问题:

What I want is not a proxy but to read all http responses (in text) that coming into my browser application.

I'm working with Qt so I need something can be loaded with Qt. So no much hope for mono.

Under windows I found Titanium Web Proxy / FiddlerCore / Nekoxy. Quite a lot of libraries written in C#. I wrote a wrapper to expose their functions to COM visible then I managed to load with Qt.

However I find nothing I can do with OSX.

I'm ok to write by myself but find little hint how to do it.

What I need is just three functions

  1. startProxy(int port[, some handle to my app]): to redirect all http transitions pass through my proxy of 127.0.0.1:port
  2. onAfterSessionComplete(string requestBodyAsString, string requestPathAndQuery, string responseBodyAsString, int resultCode, string mimeType, ): called when any http request is finished
  3. shutdown()

So any hint to do this on OSX? Best if there is some available libs open source like https://github.com/justcoding121/Titanium-Web-Proxy

BTW, I found mitmproxy, tinyproxy but I cannot find a good way to implement the 3 funcs above. And all I need is jut read http response that go through my app (written with Qt)

P.S. I know Qt has networkAccessManager but it no longer works with QtWebEngine.