@@ -365,6 +365,53 @@ public async Task IfModifiedSinceDateLessThanLastModifiedShouldReturn200(HttpMet
365
365
Assert . Equal ( HttpStatusCode . OK , res2 . StatusCode ) ;
366
366
}
367
367
368
+ [ Theory ]
369
+ [ MemberData ( nameof ( SupportedMethods ) ) ]
370
+ public async Task InvalidIfUnmodifiedSinceDateFormatGivesNormalGet ( HttpMethod method )
371
+ {
372
+ TestServer server = StaticFilesTestServer . Create ( app => app . UseFileServer ( ) ) ;
373
+
374
+ HttpResponseMessage res = await server
375
+ . CreateRequest ( "/SubFolder/extra.xml" )
376
+ . AddHeader ( "If-Unmodified-Since" , "bad-date" )
377
+ . SendAsync ( method . Method ) ;
378
+
379
+ Assert . Equal ( HttpStatusCode . OK , res . StatusCode ) ;
380
+ }
381
+
382
+ [ Theory ]
383
+ [ MemberData ( nameof ( SupportedMethods ) ) ]
384
+ public async Task FutureIfUnmodifiedSinceDateFormatGivesNormalGet ( HttpMethod method )
385
+ {
386
+ TestServer server = StaticFilesTestServer . Create ( app => app . UseFileServer ( ) ) ;
387
+
388
+ HttpResponseMessage res = await server
389
+ . CreateRequest ( "/SubFolder/extra.xml" )
390
+ . And ( req => req . Headers . IfUnmodifiedSince = DateTimeOffset . Now . AddYears ( 1 ) )
391
+ . SendAsync ( method . Method ) ;
392
+
393
+ Assert . Equal ( HttpStatusCode . OK , res . StatusCode ) ;
394
+ }
395
+
396
+ [ Theory ]
397
+ [ MemberData ( nameof ( SupportedMethods ) ) ]
398
+ public async Task IfUnmodifiedSinceDateLessThanLastModifiedShouldReturn412 ( HttpMethod method )
399
+ {
400
+ TestServer server = StaticFilesTestServer . Create ( app => app . UseFileServer ( ) ) ;
401
+
402
+ HttpResponseMessage res1 = await server
403
+ . CreateRequest ( "/SubFolder/extra.xml" )
404
+ . SendAsync ( method . Method ) ;
405
+
406
+ HttpResponseMessage res2 = await server
407
+ . CreateRequest ( "/SubFolder/extra.xml" )
408
+ . And ( req => req . Headers . IfUnmodifiedSince = DateTimeOffset . MinValue )
409
+ . SendAsync ( method . Method ) ;
410
+
411
+ Assert . Equal ( HttpStatusCode . PreconditionFailed , res2 . StatusCode ) ;
412
+ }
413
+
414
+
368
415
public static IEnumerable < object > SupportedMethods => new [ ]
369
416
{
370
417
new [ ] { HttpMethod . Get } ,
0 commit comments