private Bundle.EntryComponent doRequest(Bundle.EntryComponent interaction) { byte[] outBody; var request = interaction.ToHttpRequest(Prefer, PreferredFormat, UseFormatParameter, out outBody); #if !PORTABLE45 request.Timeout = Timeout; #endif LastRequest = request; if (BeforeRequest != null) BeforeRequest(request, outBody); // Make sure the HttpResponse gets disposed! // using (HttpWebResponse webResponse = (HttpWebResponse)await request.GetResponseAsync(new TimeSpan(0, 0, 0, 0, Timeout))) using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponseNoEx()) { try { //Read body before we call the hook, so the hook cannot read the body before we do var inBody = readBody(webResponse); LastResponse = webResponse; if (AfterResponse != null) AfterResponse(webResponse,inBody); // Do this call after AfterResponse, so this will be called, even if exceptions are thrown by ToBundleEntry() return webResponse.ToBundleEntry(inBody); } catch (AggregateException ae) { //EK: This code looks weird. Is this correct? if (ae.GetBaseException() is WebException) { } throw ae.GetBaseException(); } } }