async Task PreRequestHandlerExecuteAsync(Object sender, EventArgs e) { // Insert handling here for any requests which can potentially contain a body and that we intend to redirect. We must // process the request here because if the client is using the Expect: 100-Continue header, then we should issue our // final (redirect) status BEFORE IIS sends the 100 Continue response. This way the blob content is never sent to us. var result = await WebOperationRunner.DoHandlerAsync("App.PreRequestHandlerExecuteAsync", async() => await StorageOperationsHandler.HandlePrePipelineOperationAsync(DashHttpRequestWrapper.Create(this.Request, true))); if (result != null) { switch (result.StatusCode) { case HttpStatusCode.Redirect: this.Response.Redirect(result.Location, false); if (!String.IsNullOrWhiteSpace(result.SignedLocation)) { this.Response.AppendHeader("x-ms-redirect-signature", result.SignedLocation); } if (result.Headers != null) { foreach (var header in result.Headers .SelectMany(headerGroup => headerGroup .Select(headerItem => Tuple.Create(headerGroup.Key, headerItem)))) { this.Response.AppendHeader(header.Item1, header.Item2); } } break; case HttpStatusCode.NotFound: this.Response.StatusCode = (int)HttpStatusCode.NotFound; this.Response.StatusDescription = "The specified blob does not exist."; this.Response.ContentType = "application/xml"; this.Response.Write(String.Format(@" <?xml version='1.0' encoding='utf-8'?> <Error> <Code>BlobNotFound</Code> <Message>The specified blob does not exist.\n Time:{0:o}</Message> </Error>", DateTime.UtcNow)); break; default: System.Diagnostics.Debug.Assert(false); this.Response.StatusCode = (int)result.StatusCode; break; } this.CompleteRequest(); } }
public static HandlerResult BlobRequest(string method, string uri, IEnumerable <Tuple <string, string> > headers) { WebApiTestRunner.SetupRequest(uri, method); return(StorageOperationsHandler.HandlePrePipelineOperationAsync( new MockHttpRequestWrapper(method, uri, headers)).Result); }