Replace Constants.CompletedTask with Task.CompletedTask (#235)
This commit is contained in:
parent
d3708e16e2
commit
6b18dea711
|
|
@ -16,14 +16,5 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
internal const int Status304NotModified = 304;
|
internal const int Status304NotModified = 304;
|
||||||
internal const int Status412PreconditionFailed = 412;
|
internal const int Status412PreconditionFailed = 412;
|
||||||
internal const int Status416RangeNotSatisfiable = 416;
|
internal const int Status416RangeNotSatisfiable = 416;
|
||||||
|
|
||||||
internal static readonly Task CompletedTask = CreateCompletedTask();
|
|
||||||
|
|
||||||
private static Task CreateCompletedTask()
|
|
||||||
{
|
|
||||||
var tcs = new TaskCompletionSource<object>();
|
|
||||||
tcs.SetResult(null);
|
|
||||||
return tcs.Task;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = 301;
|
context.Response.StatusCode = 301;
|
||||||
context.Response.Headers[HeaderNames.Location] = context.Request.PathBase + context.Request.Path + "/" + context.Request.QueryString;
|
context.Response.Headers[HeaderNames.Location] = context.Request.PathBase + context.Request.Path + "/" + context.Request.QueryString;
|
||||||
return Constants.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match found, re-write the url. A later middleware will actually serve the file.
|
// Match found, re-write the url. A later middleware will actually serve the file.
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = 301;
|
context.Response.StatusCode = 301;
|
||||||
context.Response.Headers[HeaderNames.Location] = context.Request.PathBase + context.Request.Path + "/" + context.Request.QueryString;
|
context.Response.Headers[HeaderNames.Location] = context.Request.PathBase + context.Request.Path + "/" + context.Request.QueryString;
|
||||||
return Constants.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _formatter.GenerateContentAsync(context, contents);
|
return _formatter.GenerateContentAsync(context, contents);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
if (HttpMethods.IsHead(context.Request.Method))
|
if (HttpMethods.IsHead(context.Request.Method))
|
||||||
{
|
{
|
||||||
// HEAD, no response body
|
// HEAD, no response body
|
||||||
return Constants.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
PathString requestPath = context.Request.PathBase + context.Request.Path;
|
PathString requestPath = context.Request.PathBase + context.Request.Path;
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
ApplyResponseHeaders(statusCode);
|
ApplyResponseHeaders(statusCode);
|
||||||
|
|
||||||
_logger.LogHandled(statusCode, SubPath);
|
_logger.LogHandled(statusCode, SubPath);
|
||||||
return Constants.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendAsync()
|
public async Task SendAsync()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue