From ea1e708f2fc179c5fc0bf1eda83482ad0ce7ea33 Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Thu, 17 Oct 2019 15:13:41 +0800 Subject: ... --- Timeline/Controllers/UserAvatarController.cs | 3 ++- Timeline/Startup.cs | 13 +++---------- Timeline/Timeline.csproj | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'Timeline') diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index e7e12d0b..e77076ca 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -122,7 +122,8 @@ namespace Timeline.Controllers return BadRequest(new CommonResponse(ErrorCodes.Put_Content_UnmatchedLength_Less, $"Content length in header is {contentLength} but actual length is {bytesRead}.")); - if (Request.Body.ReadByte() != -1) + var extraByte = new byte[1]; + if (await Request.Body.ReadAsync(extraByte) != 0) return BadRequest(new CommonResponse(ErrorCodes.Put_Content_UnmatchedLength_Bigger, $"Content length in header is {contentLength} but actual length is bigger than that.")); diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index f5ffe94e..7552df2e 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -2,10 +2,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using Timeline.Authenticate; using Timeline.Configs; using Timeline.Entities; @@ -52,14 +50,7 @@ namespace Timeline services.AddDbContext(options => { - options.UseMySql(databaseConfig.ConnectionString) - .ConfigureWarnings(warnings => - { - if (Environment.IsProduction()) - warnings.Log(RelationalEventId.QueryClientEvaluationWarning); - else - warnings.Throw(RelationalEventId.QueryClientEvaluationWarning); - }); + options.UseMySql(databaseConfig.ConnectionString); }); services.AddHttpClient(); @@ -78,9 +69,11 @@ namespace Timeline app.UseRouting(); app.UseAuthentication(); + app.UseAuthorization(); app.UseEndpoints(endpoints => { + endpoints.MapControllers(); }); } } diff --git a/Timeline/Timeline.csproj b/Timeline/Timeline.csproj index 836376d9..f01b8e31 100644 --- a/Timeline/Timeline.csproj +++ b/Timeline/Timeline.csproj @@ -13,7 +13,7 @@ - + -- cgit v1.2.3