Can HttpWebResponse
be obtained from Html Agility Pack HtmlWeb
?
As in, if I call:
HtmlWeb web = new HtmlWeb ();
HtmlDocument document = web.Load ("http://stackoverflow.com/");
Is there a convenient method to retrieve the HttpWebResponse
from the web
instance to view headers - such as to retrieve header properties like content type?
There are pre and post delegates, which will work:
HtmlWeb web = new HtmlWeb ();
web.PreRequest = delegate (HttpWebRequest request) {
request.Timeout = 10 * 1000;
return true;
};
web.PostResponse = delegate (HttpWebRequest request, HttpWebResponse response) {
//response.Headers;
//response.ContentType;
};
HtmlDocument document = web.Load ("http://stackoverflow.com/");
Instead, is there a way to get the response something like: (HttpWebResponse)web.GetResponse();
charset=...
suffix and byte order marks. Can be handy if you're fetching from diverse sources. – spender Aug 31 '14 at 21:09