File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
src/WebApi.OutputCache.V2
test/WebApi.OutputCache.V2.Tests Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ public override void OnActionExecuting(HttpActionContext actionContext)
167
167
var val = _webApiCache . Get < byte [ ] > ( cachekey ) ;
168
168
if ( val == null ) return ;
169
169
170
- var contenttype = _webApiCache . Get < MediaTypeHeaderValue > ( cachekey + Constants . ContentTypeKey ) ?? new MediaTypeHeaderValue ( cachekey . Split ( new [ ] { ':' } , 2 ) [ 1 ] ) ;
170
+ var contenttype = _webApiCache . Get < MediaTypeHeaderValue > ( cachekey + Constants . ContentTypeKey ) ?? new MediaTypeHeaderValue ( cachekey . Split ( new [ ] { ':' } , 2 ) [ 1 ] . Split ( ';' ) [ 0 ] ) ;
171
171
172
172
actionContext . Response = actionContext . Request . CreateResponse ( ) ;
173
173
actionContext . Response . Content = new ByteArrayContent ( val ) ;
Original file line number Diff line number Diff line change @@ -293,6 +293,19 @@ public void can_handle_ihttpactionresult_with_non_default_media_type()
293
293
}
294
294
295
295
296
+ [ Test ]
297
+ public void can_handle_media_type_when_cache_has_expired_during_request ( )
298
+ {
299
+ var client = new HttpClient ( _server ) ;
300
+ var req = new HttpRequestMessage ( HttpMethod . Get , _url + "Get_ihttpactionresult" ) ;
301
+ req . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "text/xml" ) ) ;
302
+ _cache . Setup ( o => o . Contains ( It . IsAny < string > ( ) ) ) . Returns ( true ) ;
303
+ _cache . Setup ( o => o . Get < MediaTypeHeaderValue > ( It . Is ( ( string key ) => key . Contains ( Constants . ContentTypeKey ) ) ) ) . Returns ( ( MediaTypeHeaderValue ) null ) ;
304
+ var result = client . SendAsync ( req ) . Result ;
305
+ Assert . That ( result . IsSuccessStatusCode , Is . True ) ;
306
+ }
307
+
308
+
296
309
//[Test]
297
310
//public void must_add_querystring_to_cache_params()
298
311
//{
You can’t perform that action at this time.
0 commit comments