private HResponse performRequest(HttpWebRequest request) { Log.Debug(1, "Requested ({0}) URL \"{1}\"".Fmt(request.Method, request.RequestUri.OriginalString)); for (int i = 0; i < request.Headers.Count; i++) { Log.Debug(3, " " + request.Headers.AllKeys[i] + ": " + request.Headers[i]); } if (request.CookieContainer != null && request.CookieContainer.Count > 0) { Log.Debug(3, " Cookie: " + request.CookieContainer.GetCookieHeader(request.RequestUri)); } HResponse result; HttpWebResponse resp; try { resp = (HttpWebResponse)request.GetResponse(); if (resp == null) { throw new WebException("Received a null response."); } result = new HResponse(resp); } catch (WebException e) { if (e.Response == null) { throw new WebException("Caught WebException containing no response.", e); } else { result = new HResponse(resp = (HttpWebResponse)e.Response); } } Log.Debug(2, "Response: " + result.StatusCode + " - " + result.DataString.SubstringSafe(0, 50)); for (int i = 0; i < resp.Headers.Count; i++) { Log.Debug(3, " " + resp.Headers.AllKeys[i] + ": " + resp.Headers[i]); } return(result); }
private HResponse performRequest(HttpWebRequest request) { Log.Debug(1, "Requested ({0}) URL \"{1}\"".Fmt(request.Method, request.RequestUri.OriginalString)); for (int i = 0; i < request.Headers.Count; i++) Log.Debug(3, " " + request.Headers.AllKeys[i] + ": " + request.Headers[i]); if (request.CookieContainer != null && request.CookieContainer.Count > 0) Log.Debug(3, " Cookie: " + request.CookieContainer.GetCookieHeader(request.RequestUri)); HResponse result; HttpWebResponse resp; try { resp = (HttpWebResponse) request.GetResponse(); if (resp == null) throw new WebException("Received a null response."); result = new HResponse(resp); } catch (WebException e) { if (e.Response == null) throw new WebException("Caught WebException containing no response.", e); else result = new HResponse(resp = (HttpWebResponse) e.Response); } Log.Debug(2, "Response: " + result.StatusCode + " - " + result.DataString.SubstringSafe(0, 50)); for (int i = 0; i < resp.Headers.Count; i++) Log.Debug(3, " " + resp.Headers.AllKeys[i] + ": " + resp.Headers[i]); return result; }