We have a WPF application created in .Net Framework 3.5 SP1, use开发者_运维问答d for displaying various Web Application. The WPF application uses a Web Browser control to display the web pages of the various applications.
We instrument these web pages to measure the response time and various other parameters, of which Page size is an important parameter.
The code below describes how we are accessing Page size.
void wbEvents1_DocumentComplete(object pDisp, ref object URL)
{ objInstrument.PageSize = Convert.ToInt32(((mshtml.HTMLDocumentClass)(((SHDocVw.IWebBrowser2)pDisp).Document)).fileSize);
}
But we are facing following issues over here:
We are able to get only the filesize of the Document object i.e the size of the downloaded HTML only without the size of its associated resources like (.css; .js; .img, etc).What we need is the holistic Page size of the HTML document, including all the resource objects within the HTML(.css; .js; .img, etc) .
Also in case if the downloaded page has any of the following parameters in its header; IE does not return any value for the fileSize attribute.
Cache-Control = no-cache
Pragma = no-cache
Request for help in resolving the above 2 issues that we are facing at earliest.
This is not a direct answer, but perhaps you could consider fetching the web pages in question through a local proxy, which could monitor and instrument all traffic and communicate it back to parent app via IPC if run out-of-process.
Placing a proxy in between the browser and the net would give you exact and complete measurement of bytes transfered, time spent on each request, etc. There are probably plenty of existing monitoring solutions which will break down traffic by object type, etc. or you could write your own analysis piece given raw information from the proxy. Perhaps, Squid + log-file analyzer plugin or adapt an existing proxy to gather the needed stats (in the spirit of CharlesProxy).
To instruct the browser control to user a proxy, you can use InternetSetOption() (there's an example).
精彩评论