private static void RequestStreamGotten(IAsyncResult ar) { BypassContext ctx = (BypassContext)ar.AsyncState; try { ctx.cloudRequestStream = ctx.cloudRequest.EndGetRequestStream(ar); StreamHelper.BeginCopy(ctx.request.InputStream, ctx.cloudRequestStream, RequestDone, ctx); } catch (Exception e) { logger.Warn("Error get request stream to cloud", e); HttpHelper.RespondFailure(ctx.response, e, 400); } }
private static void RequestDone(IAsyncResult ar) { BypassContext ctx = (BypassContext)ar.AsyncState; try { StreamHelper.EndCopy(ar); ctx.cloudRequest.BeginGetResponse(ResponseGotten, ctx); } catch (WebException e) { logger.Warn("forward to cloud error", e); ReplyCloudError(ctx.response, e); } catch (Exception e) { logger.Warn("forward to cloud error", e); HttpHelper.RespondFailure(ctx.response, e, 400); } }
private static void ResponseGotten(IAsyncResult ar) { BypassContext ctx = (BypassContext)ar.AsyncState; try { ctx.cloudResponse = (HttpWebResponse)ctx.cloudRequest.EndGetResponse(ar); CopyResponseData(ctx.cloudResponse, ctx.response); } catch (WebException e) { logger.Warn("forward to cloud error", e); ReplyCloudError(ctx.response, e); } catch (Exception e) { logger.Warn("forward to cloud error", e); HttpHelper.RespondFailure(ctx.response, e, 400); } }