Add header to requests with Charles

做~自己de王妃 提交于 2019-12-23 23:25:53

问题


I am trying to use Charles (http://www.charlesproxy.com) to add a header to every HTTP request I execute in a browser. The web app I am using is relying on a header to work correctly. I have setup a rewrite rule to add a header like this:

Charles error log shows that the request is matched and it says it added the header:

2017/05/24 16:34:04 INFO     com.xk72.charles.tools.rewrite.RewriteFilter          CONNECT https://www.googleapis.com   Testing: Add Header: MY_HEADER:MY_HEADER_VALUE
2017/05/24 16:34:04 INFO     com.xk72.charles.tools.rewrite.RewriteFilter          CONNECT https://www.googleapis.com   Matched: Add Header: MY_HEADER:MY_HEADER_VALUE  Rewrite: MY_HEADER_VALUE

But when I try to open the web app in question in Chrome by typing in a url and when I inspect the traffic in Chrome Dev Tools, I don't see the header and my app doesn't work.


回答1:


Your browser will show the request as it as sent from the browser. If the request is modified after being sent, e.g: by a proxy or a gateway, these changes will not be reflected in that view (but will be still applied to the request).

Charles should show the edit request.

In addition you can use a traffic monitor (aka sniffer) to see exactly what is being transmitted, such as Wireshark, however Charles should suffice in this case.



来源:https://stackoverflow.com/questions/44168074/add-header-to-requests-with-charles

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