Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
To help with this issue one could add an http-error-event as follows:
Add to WebKitBrowserEvents.cs:
public delegate void HTTPErrorEventHandler(object sender, HTTPErrorEventArgs e);
public class HTTPErrorEventArgs : EventArgs
{
public WebException WebException { get; internal set; }
}
-------------------------------------------
Add to WebKitBrowser.cs
public event HTTPErrorEventHandler HTTPErrorOccured = delegate { };
Add a RunWorkerComplete Event to
frameLoadDelegate_DidStartProvisionalLoadForFrame()
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
bw.RunWorkerCompleted += new
RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
The event handler:
void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Result != null && e.Result.GetType().Equals(typeof(WebException)))
{
HTTPErrorOccured(this, new HTTPErrorEventArgs() { WebException = (WebException)e.Result });
}
}
Change the Method "bw_DoWork" to catch WebExceptions:
void bw_DoWork(object sender, DoWorkEventArgs e)
{
HeadersAvailableEventArgs h = e.Argument as HeadersAvailableEventArgs;
try
{
string Url = h.Url.ToString();
WebRequest WebRequestObject = HttpWebRequest.Create(Url);
WebResponse ResponseObject = WebRequestObject.GetResponse();
List<Header> headers = new List<Header>();
foreach (string HeaderKey in ResponseObject.Headers)
headers.Add(new Header(HeaderKey, ResponseObject.Headers[HeaderKey]));
ResponseObject.Close();
h.Headers = headers.ToArray();
HeadersAvailable(this, h);
}
catch (WebException ex)
{
e.Result = ex;
}
}
Maybe you want to integrate this into the next release?
Original comment by browseem...@googlemail.com
on 16 Oct 2012 at 1:03
Code implemented in 3.0.1. Thanks for this contribution!
Original comment by tsumalis96@gmail.com
on 10 Nov 2012 at 3:11
Original issue reported on code.google.com by
browseem...@googlemail.com
on 16 Oct 2012 at 12:21