How can I add an extra http header using IHTTPNegotiate?

陌路散爱 提交于 2019-12-04 11:26:51

I'm silently assuming you're intercepting traffic by both implementing IInternetProcol and the IInternetProtocolSink and IInternetBindInfo interfaces, and call the original IInternetProtocol to have the work done. In that case it's important to know the direction of who calls who.

If the original handler want the additional headers, it will first cast your IInternetProtocolSink into a IServiceProvider interface (with QueryInterface), and call QueryService for an IHttpNegotiate instance. By convenience you can add the current object instance and also implement IHttpNegotiate on the same object, but this is not required.

When the BeginTransaction method of your IHttpNegotiate gets called, get a IHttpNegotiate instance on the ProtSink of the Start call, call BeginTransaction and add your header(s) before passing them to the caller.

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