How can I add an extra header to the request using IHTTPNegotiate? I added the interface but functions BeginningTransaction & OnResponse
never get called.
TNameSpaceHandler = class(TComObject, IInternetProtocol, IHttpNegotiate)
...
function BeginningTransaction(szURL, szHeaders: LPCWSTR; dwReserved: DWORD;
out szAdditionalHeaders: LPWSTR): HResult; stdcall;
function OnResponse(dwResponseCode: DWORD; szResponseHeaders, szRequestHeaders: LPCWSTR;
out szAdditionalRequestHeaders: LPWSTR): HResult; stdcall;
...
end;
I'm silently assuming you're intercepting traffic by both implementing
IInternetProcol
and theIInternetProtocolSink
andIInternetBindInfo
interfaces, and call the originalIInternetProtocol
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 aIServiceProvider
interface (withQueryInterface
), and callQueryService
for anIHttpNegotiate
instance. By convenience you can add the current object instance and also implementIHttpNegotiate
on the same object, but this is not required.When the
BeginTransaction
method of yourIHttpNegotiate
gets called, get aIHttpNegotiate
instance on theProtSink
of the Start call, callBeginTransaction
and add your header(s) before passing them to the caller.