33
44using System ;
55using System . IO ;
6+ using System . Net ;
67using System . Net . Http ;
78using System . Threading . Tasks ;
9+ using Microsoft . AspNetCore . Http ;
810using SixLabors . ImageSharp . Formats ;
911using SixLabors . ImageSharp . Web . Tests . TestUtilities ;
1012using Xunit ;
@@ -34,6 +36,8 @@ public async Task CanProcessAndResolveImage(string url)
3436
3537 Assert . NotNull ( response ) ;
3638 Assert . True ( response . IsSuccessStatusCode ) ;
39+ Assert . True ( response . Content . Headers . ContentLength > 0 ) ;
40+ Assert . Equal ( format . DefaultMimeType , response . Content . Headers . ContentType . MediaType ) ;
3741
3842 ( Image Image , IImageFormat Format ) actual = await Image . LoadWithFormatAsync ( await response . Content . ReadAsStreamAsync ( ) ) ;
3943 using Image image = actual . Image ;
@@ -46,12 +50,29 @@ public async Task CanProcessAndResolveImage(string url)
4650
4751 Assert . NotNull ( response ) ;
4852 Assert . True ( response . IsSuccessStatusCode ) ;
53+ Assert . True ( response . Content . Headers . ContentLength > 0 ) ;
54+ Assert . Equal ( format . DefaultMimeType , response . Content . Headers . ContentType . MediaType ) ;
4955
5056 ( Image Image , IImageFormat Format ) cachedActual = await Image . LoadWithFormatAsync ( await response . Content . ReadAsStreamAsync ( ) ) ;
5157 using Image cached = cachedActual . Image ;
5258
5359 Assert . Equal ( Width , cached . Width ) ;
5460 Assert . Equal ( format , actual . Format ) ;
61+
62+ // 304 response
63+ var request = new HttpRequestMessage
64+ {
65+ RequestUri = new Uri ( url + Command ) ,
66+ Method = HttpMethod . Get ,
67+ } ;
68+
69+ request . Headers . IfModifiedSince = DateTimeOffset . UtcNow ;
70+
71+ response = await this . HttpClient . SendAsync ( request ) ;
72+
73+ Assert . Equal ( HttpStatusCode . NotModified , response . StatusCode ) ;
74+ Assert . Equal ( 0 , response . Content . Headers . ContentLength ) ;
75+ Assert . Equal ( format . DefaultMimeType , response . Content . Headers . ContentType . MediaType ) ;
5576 }
5677 }
5778}
0 commit comments