1- using Azure ;
2- using Microsoft . AspNetCore . Http ;
3- using Microsoft . AspNetCore . Mvc ;
1+ using Microsoft . AspNetCore . Http ;
42using System . Collections . Specialized ;
5- using System . Diagnostics ;
63using System . Dynamic ;
74using System . Net ;
8- using System . Net . Http ;
95using System . Net . Mime ;
106using System . Reflection ;
117using System . Text . RegularExpressions ;
@@ -55,8 +51,9 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
5551 if ( ! string . IsNullOrEmpty ( rawIfModifiedSince ) )
5652 {
5753 httpContext . Response . StatusCode = StatusCodes . Status304NotModified ;
54+
5855 // Do not process the request at all, stop here.
59- return ;
56+ await returnResponseAsync ( httpContext , "" , apiCancellationToken , HttpStatusCode . NotModified , false ) ;
6057 }
6158
6259 try
@@ -92,14 +89,11 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
9289 }
9390 else if ( result . statusCode == HttpStatusCode . OK )
9491 {
95- //
92+
9693 httpContext . Response . ContentType = result . mimeType ;
9794 httpContext . Response . Headers . Add ( "Expires" , DateTime . Now . AddYears ( 1 ) . ToString ( ) ) ;
9895 httpContext . Response . Headers . Add ( "Last-Modified" , DateTime . Now . ToString ( ) ) ;
9996
100- //httpContext.Response.Cache.SetLastModified(DateTime.Now);
101- //httpContext.Response.Cache.SetExpires(DateTime.Now.AddYears(1));
102-
10397 if ( ! string . IsNullOrEmpty ( result . fileName ) )
10498 {
10599 httpContext . Response . Headers . Add ( "Content-Disposition" , new ContentDisposition { Inline = true , FileName = result . fileName } . ToString ( ) ) ;
@@ -114,7 +108,7 @@ public async Task ProcessRequest(HttpContext httpContext, CancellationTokenSourc
114108 await returnResponseAsync ( httpContext , fullFileName , apiCancellationToken , HttpStatusCode . OK , true ) ;
115109 }
116110 else
117- {
111+ {
118112 await returnResponseAsync ( httpContext , result . response , apiCancellationToken , HttpStatusCode . OK ) ;
119113 }
120114 }
@@ -150,7 +144,7 @@ private async Task ParseError(HttpContext context, HttpStatusCode statusCode,Can
150144 Log . Instance . Info ( "IP: " + ApiServicesHelper . WebUtility . GetIP ( ) + ", Status Code: " + statusCode . ToString ( ) + ", Status Description: " + statusDescription ) ;
151145
152146 if ( ! string . IsNullOrEmpty ( statusDescription ) )
153- await returnResponseAsync ( context , Utility . JsonSerialize_IgnoreLoopingReference ( statusDescription ) , sourceToken , statusCode ) ;
147+ await returnResponseAsync ( context , statusDescription , sourceToken , statusCode ) ;
154148
155149
156150 }
0 commit comments