本文介绍了在 IE 中挂钩 http/https 协议会导致 GET 请求是顺序的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PassthruAPP 方法挂钩到 IE 发出的 HTTP/HTTPS 请求.

I'm using the PassthruAPP method to hook into HTTP/HTTPS requests made by IE.

它在大多数情况下运行良好,但是我发现了一个问题.一次只有一个下载线程处于活动状态,通常 IE 使用两个下载线程.我可以看到创建了两个 IInternetProtocol 对象,但 IE 一次只使用一个.

It's working well for the most part, however I noticed a problem. Only one download thread is active at a time, normally IE uses two download threads. I can see two IInternetProtocol objects getting created, but IE uses only one at a time.

IE7 会出现这种情况,我还没有尝试过其他版本.

This is happening with IE7, I haven't tried with other versions yet.

问题似乎在于,当为其任何默认处理程序调用 IInternetSession::RegisterNameSpace 时,IE 会退回到一次下载一个项目.即使我正在注册 HTTPS 处理程序,下面的代码也会导致 HTTP 下载是连续的.注册 'file://' 会导致同样的问题.

The problem seems to be that IE falls back to downloading items one at a time when IInternetSession::RegisterNameSpace is called for any of its default handlers. The code below causes HTTP downloads to be sequential even though I am registering a HTTPS handler. Registering for 'file://' causes the same problem.

CComPtr<IInternetSession> spSession;
CoInternetGetSession(0, &spSession, 0);

MetaFactory::CreateInstance(CLSID_HttpSProtocol, &m_spCFHTTPS);
spSession->RegisterNameSpace(m_spCFHTTPS, CLSID_NULL, L"https", 0, 0, 0)

这总是发生在页面上的前几项,但似乎在文档完成后,可以再次发生并发下载.例如,在页面完成加载后执行的 Javascript 代码可以同时加载图像.

This always happens for the first few items on the page, but it seems that after the document complete is issued, concurrent downloads can occur again. For example Javascript code that is executed after the page has finished loading can load images concurrently just fine.

推荐答案

可以通过在已注册的 HTTP/HTTPS 协议上为 InternetProtocolRootEx::StartEx() 修补 COM VTable 来解决此问题.由于这不会直接替换协议处理程序,因此 IE 不会回退到单线程模型.

It's possible to get around this problem by patching the COM VTable for InternetProtocolRootEx::StartEx() on the registered HTTP/HTTPS protocols. Since this does not replace the protocol handler directly, IE won't fallback to the single thread model.

这里描述了该技术:

http://web.archive.org/web/20130313164317/http://www.blackfishsoftware.com/blog/don/passthroughapp_bho_toolbar_intercepting_requests_responses

这篇关于在 IE 中挂钩 http/https 协议会导致 GET 请求是顺序的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 22:09