public async Task Handle(IOwinContext owinContext, Func <Task> next) { if (_stopping) { owinContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; owinContext.Response.Write("Stopping"); await next().ConfigureAwait(false); return; } using (_tracker.BeginDelivery()) { var responseProxy = new HttpResponseSendEndpointProvider(_receiveSettings, owinContext, _inputAddress, _sendPipe); var context = new HttpReceiveContext(owinContext, false, _receiveObserver, responseProxy, _receiveSettings.PublishEndpointProvider); try { await _receiveObserver.PreReceive(context).ConfigureAwait(false); await _receivePipe.Send(context).ConfigureAwait(false); await context.CompleteTask.ConfigureAwait(false); //TODO: Push into Pipe! -- cant' be on the receive pipe because it doesn't have the content if (!owinContext.Response.ContentLength.HasValue) { owinContext.Response.StatusCode = (int)HttpStatusCode.Accepted; owinContext.Response.Write(""); } await next().ConfigureAwait(false); await _receiveObserver.PostReceive(context).ConfigureAwait(false); } catch (Exception ex) { await _receiveObserver.ReceiveFault(context, ex).ConfigureAwait(false); //TODO: Push into pipe? owinContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; } finally { context.Dispose(); } } }
public async Task Handle(IOwinContext owinContext, Func<Task> next) { if (_stopping) { owinContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable; owinContext.Response.Write("Stopping"); await next().ConfigureAwait(false); return; } using (_tracker.BeginDelivery()) { var responseProxy = new HttpResponseSendEndpointProvider(_receiveSettings, owinContext, _inputAddress, _sendPipe); var context = new HttpReceiveContext(owinContext, false, _receiveObserver, responseProxy, _receiveSettings.PublishEndpointProvider); try { await _receiveObserver.PreReceive(context).ConfigureAwait(false); await _receivePipe.Send(context).ConfigureAwait(false); await context.CompleteTask.ConfigureAwait(false); //TODO: Push into Pipe! -- cant' be on the receive pipe because it doesn't have the content if (!owinContext.Response.ContentLength.HasValue) { owinContext.Response.StatusCode = (int)HttpStatusCode.Accepted; owinContext.Response.Write(""); } await next().ConfigureAwait(false); await _receiveObserver.PostReceive(context).ConfigureAwait(false); } catch (Exception ex) { await _receiveObserver.ReceiveFault(context, ex).ConfigureAwait(false); //TODO: Push into pipe? owinContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError; } finally { context.Dispose(); } } }