private Bundle.BundleEntryComponent doRequest(Bundle.BundleEntryComponent 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(); } } }
private Bundle.BundleEntryComponent doRequest(Bundle.BundleEntryComponent interaction) { var request = interaction.ToHttpRequest(Prefer, PreferredFormat, UseFormatParameter); #if (!PORTABLE45 && !NETCOREAPP1_1) request.Timeout = Timeout; #endif if (BeforeRequest != null) { BeforeRequest(request); } // 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 { var response = webResponse.ToBundleEntry(); if (AfterResponse != null) { AfterResponse(webResponse, response.TransactionResponse, response.Resource); } return(response); } catch (AggregateException ae) { //EK: This code looks weird. Is this correct? if (ae.GetBaseException() is WebException) { } throw ae.GetBaseException(); } } }