1- namespace Microsoft . AspNet . OutputCache {
1+ using System . Text ;
2+
3+ namespace Microsoft . AspNet . OutputCache {
24 using System . Collections . Generic ;
35 using System ;
46 using System . Linq ;
1012 using System . Web . Configuration ;
1113 using System . Diagnostics ;
1214 using System . Configuration ;
13-
15+ using Resource ;
1416 /// <summary>
1517 /// OutputCache Async Module, this Module is able to use Async type of OutputCache Providers
1618 /// </summary>
@@ -62,7 +64,7 @@ private async Task OnEnterAsync(object source, EventArgs eventArgs) {
6264 }
6365
6466 // Create a lookup key. Also store the key in global parameter _key to be used inside OnLeave() later
65- string key = _key = await OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , null ) ;
67+ string key = _key = OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , null ) ;
6668
6769 // Lookup the cache vary using the key
6870 object item = await _outputCacheHelper . Get ( key ) ;
@@ -178,7 +180,7 @@ private async Task CacheResponse(HttpContext context, HttpResponse response) {
178180 string [ ] varyByParams = settings . IgnoreParams ? null : settings . VaryByParams ;
179181 /* Create the key if it was not created in OnEnter */
180182 if ( _key == null ) {
181- _key = await OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , null ) ;
183+ _key = OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , null ) ;
182184 Debug . Assert ( _key != null , "_key != null" ) ;
183185 }
184186 if ( settings . VaryByContentEncodings == null && varyByHeaders == null && varyByParams == null &&
@@ -221,16 +223,16 @@ private async Task CacheResponse(HttpContext context, HttpResponse response) {
221223 VaryByAllParams = varyByAllParams ,
222224 VaryByCustom = settings . VaryByCustom
223225 } ;
224- keyRawResponse = await OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , cachedVary ) ;
226+ keyRawResponse = OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , cachedVary ) ;
225227 if ( keyRawResponse == null ) {
226- Debug . WriteLine ( " OutputCacheModuleLeave" , "Couldn't add non-cacheable post. \n \t key=" + _key ) ;
228+ Debug . WriteLine ( SR . OutputCacheModuleLeave , string . Format ( SR . Couldnot_add_non_cacheable_post , _key ) ) ;
227229 return ;
228230 }
229231 // it is possible that the user code calculating custom vary-by
230232 // string would Flush making the response non-cacheable. Check fo it here.
231233 if ( response . HeadersWritten ) {
232- Debug . WriteLine ( " OutputCacheModuleLeave" ,
233- "Response.Flush() inside GetVaryByCustomstring \n \t key=" + _key ) ;
234+ Debug . WriteLine ( SR . OutputCacheModuleLeave ,
235+ string . Format ( SR . Response_Flush_inside_GetVaryByCustomstring , _key ) ) ;
234236 return ;
235237 }
236238 }
@@ -260,7 +262,7 @@ private async Task CacheResponse(HttpContext context, HttpResponse response) {
260262 KernelCacheUrl = kernelCacheUrl ,
261263 CachedVaryId = cachedVaryId
262264 } ;
263- Debug . WriteLine ( " OutputCacheModuleLeave" , "Adding response to cache. Key=" + keyRawResponse ) ;
265+ Debug . WriteLine ( SR . OutputCacheModuleLeave , string . Format ( SR . Adding_response_to_cache , keyRawResponse ) ) ;
264266 CacheDependency dep = OutputCacheUtility . CreateCacheDependency ( context . Response ) ;
265267 try {
266268 await _outputCacheHelper . InsertResponse ( _key , cachedVary ,
@@ -303,8 +305,8 @@ private static void GetCachedResponse(HttpContext context, HttpRequest request,
303305 }
304306 }
305307 catch {
306- Debug . WriteLine ( " OutputCacheModuleEnter" ,
307- "Ignore If-Modified-Since header, invalid format: " + ifModifiedSinceHeader ) ;
308+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
309+ string . Format ( SR . Ignore_IfModifiedSince_header , ifModifiedSinceHeader ) ) ;
308310 }
309311 }
310312 /* Check "If-None-Match" header */
@@ -331,8 +333,7 @@ private static void GetCachedResponse(HttpContext context, HttpRequest request,
331333 /*
332334 * Send 304 Not Modified
333335 */
334- Debug . WriteLine ( "OutputCacheModuleEnter" , "Hit, conditional request satisfied, status=304. Key=" + key +
335- ". Returning from OutputCacheModule::Enter" ) ;
336+ Debug . WriteLine ( SR . OutputCacheModuleEnter , string . Format ( SR . Hit_conditional_request_satisfied , key ) + "OutputCacheModule::Enter" ) ;
336337 if ( response . HeadersWritten ) {
337338 response . ClearHeaders ( ) ;
338339 }
@@ -370,8 +371,8 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
370371 string [ ] cacheDirectives = request . Headers [ "Cache-Control" ] . Split ( s_fieldSeparators ) ;
371372 foreach ( string directive in cacheDirectives ) {
372373 if ( directive == "no-cache" || directive == "no-store" ) {
373- Debug . WriteLine ( "OutputCache Module Async Enter" ,
374- "Skipping lookup because of Cache-Control: no-cache or no-store directive. Returning from OutputCacheModule::Enter") ;
374+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
375+ SR . Skipping_lookup_because_of_Cache_Control_no_cache_or_no_store_directive + " OutputCacheModule::Enter") ;
375376 return true ;
376377 }
377378 if ( directive . StartsWith ( "max-age=" ) ) {
@@ -393,8 +394,8 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
393394 if ( age < maxage ) {
394395 continue ;
395396 }
396- Debug . WriteLine ( " OutputCacheModuleEnter" ,
397- "Not returning found item due to Cache-Control: max-age directive. Returning from OutputCacheModule::Enter") ;
397+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
398+ SR . Not_returning_found_item_due_to_Cache_Control_max_age_directive + " OutputCacheModule::Enter") ;
398399 return true ;
399400 }
400401 if ( ! directive . StartsWith ( "min-fresh=" ) ) {
@@ -416,8 +417,8 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
416417 if ( fresh >= minfresh ) {
417418 continue ;
418419 }
419- Debug . WriteLine ( " OutputCacheModuleEnter" ,
420- "Not returning found item due to Cache-Control: min-fresh directive. Returning from OutputCacheModule::Enter") ;
420+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
421+ SR . Not_returning_found_item_due_to_Cache_Control_min_fresh_directive + " OutputCacheModule::Enter") ;
421422 return true ;
422423 }
423424 }
@@ -429,8 +430,8 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
429430 if ( ! pragmaDirectives . Any ( t => t == null || t == "no-cache" ) ) {
430431 return false ;
431432 }
432- Debug . WriteLine ( " OutputCacheModuleEnter" ,
433- "Skipping lookup because of Pragma: no-cache directive. Returning from OutputCacheModule::Enter") ;
433+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
434+ SR . Skipping_lookup_because_of_Pragma_no_cache_directive + " OutputCacheModule::Enter") ;
434435 return true ;
435436 }
436437 if ( settings . ValidationCallbackInfo == null || ! settings . ValidationCallbackInfo . Any ( ) ) {
@@ -445,9 +446,8 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
445446 vci . Key ( context , vci . Value , ref validationStatus ) ;
446447 switch ( validationStatus ) {
447448 case HttpValidationStatus . Invalid :
448- Debug . WriteLine ( "OutputCacheModuleEnter" ,
449- "Output cache item found but callback invalidated it. key=" + key +
450- ". Returning from OutputCacheModule::Enter" ) ;
449+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
450+ string . Format ( SR . Output_cache_item_found_but_callback_invalidated_it , key ) + " OutputCacheModule::Enter" ) ;
451451
452452 await _outputCacheHelper . Remove ( key , context ) ;
453453 return true ;
@@ -457,18 +457,16 @@ private async Task<bool> CheckHeadersToDetermineAcceptCachedCopy(string key, Htt
457457 case HttpValidationStatus . Valid :
458458 break ;
459459 default :
460- Debug . WriteLine ( "OutputCacheModuleEnter" ,
461- "Invalid validation status, ignoring it, status=" + validationStatus +
462- ". Key=" + key ) ;
460+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
461+ string . Format ( SR . Invalid_validation_status , validationStatus , key ) ) ;
463462 validationStatus = validationStatusFinal ;
464463 break ;
465464 }
466465 }
467466
468467 if ( validationStatusFinal == HttpValidationStatus . IgnoreThisRequest ) {
469- Debug . WriteLine ( "OutputCacheModuleEnter" ,
470- "Output cache item found but callback status is IgnoreThisRequest. Key=" + key +
471- ". Returning from OutputCacheModule::Enter" ) ;
468+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
469+ string . Format ( SR . Callback_status_is_IgnoreThisRequest , key ) + " OutputCacheModule::Enter" ) ;
472470 return true ;
473471 }
474472
@@ -485,7 +483,8 @@ private static bool IsValidHttpMethod(HttpRequest request) {
485483 case "POST" :
486484 break ;
487485 default :
488- Debug . WriteLine ( "Http method not GET, POST, or HEAD. Returning from OutputCacheModule::Enter" ) ;
486+ Debug . WriteLine ( "Http "
487+ + SR . method_is_not + "GET, POST, or HEAD." + SR . Returning_from + " OutputCacheModule::Enter" ) ;
489488 return false ;
490489 }
491490 return true ;
@@ -503,10 +502,10 @@ private async Task<CachedItem> CheckCacheVaryAsync(CachedVary cachedVary, HttpCo
503502 *
504503 * Skip this step if it's a VaryByNone vary policy.
505504 */
506- string key = await OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , cachedVary ) ;
505+ string key = OutputCacheHelper . CreateOutputCachedItemKeyAsync ( context , cachedVary ) ;
507506 if ( key == null ) {
508- Debug . WriteLine ( " OutputCacheModuleEnter" ,
509- "Miss, key could not be created for vary-by item. Returning from OutputCacheModule::Enter") ;
507+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
508+ string . Format ( SR . Miss_key_could_not_be_created_for_varyby_item , "Vary-By" ) + " OutputCacheModule::Enter") ;
510509 return new CachedItem { DoReturn = true , Item = null } ;
511510 }
512511 if ( cachedVary . ContentEncodings == null ) {
@@ -563,15 +562,15 @@ private static bool CheckHasQueryStringOrFormPost(HttpRequest request, string ke
563562 if ( cachedVary == null && ! settings . IgnoreParams ) {
564563 // This cached output has no vary policy, so make sure it doesn't have a query string or form post.
565564 if ( request . HttpMethod == "POST" ) {
566- Debug . WriteLine ( " OutputCacheModuleEnter" ,
567- "Output cache item found but method is POST and no VaryByParam specified. Key=" + key +
568- ". Returning from OutputCacheModule::Enter" ) ;
565+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
566+ string . Format ( SR . Method_is_POST_and_no_VaryByParam_specified , " POST" , " VaryByParam" , key ) +
567+ " OutputCacheModule::Enter" ) ;
569568 return true ;
570569 }
571570 if ( request . QueryString . Count > 0 ) {
572- Debug . WriteLine ( " OutputCacheModuleEnter" ,
573- "Output cache item found but contains a querystring and no VaryByParam specified. Key=" + key +
574- ". Returning from OutputCacheModule::Enter" ) ;
571+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
572+ string . Format ( SR . Contains_querystring_and_no_VaryByParam_specified , " querystring " , " VaryByParam " , key ) +
573+ " OutputCacheModule::Enter" ) ;
575574 return true ;
576575 }
577576 }
@@ -582,9 +581,9 @@ private static bool CheckHasQueryStringOrFormPost(HttpRequest request, string ke
582581 if ( ! rangeHeader . StartsWith ( "bytes" , StringComparison . OrdinalIgnoreCase ) ) {
583582 return false ;
584583 }
585- Debug . WriteLine ( " OutputCacheModuleEnter" ,
586- "Output cache item found but this is a Range request and IgnoreRangeRequests is true. Key=" + key +
587- ". Returning from OutputCacheModule::Enter" ) ;
584+ Debug . WriteLine ( SR . OutputCacheModuleEnter ,
585+ string . Format ( SR . Range_request_and_IgnoreRangeRequests_is_true , " Range request " , " IgnoreRangeRequests " , key ) +
586+ " OutputCacheModule::Enter" ) ;
588587 // Don't record this as a cache miss. The response for a range request is not cached, and so
589588 // we don't want to pollute the cache hit/miss ratio.
590589 return true ;
0 commit comments