1
1
using System . IO . Compression ;
2
2
using System . Net ;
3
+ using System . Net . Http . Headers ;
3
4
using System . Security . Cryptography ;
4
5
using Microsoft . AspNetCore . Builder ;
5
6
using Swashbuckle . AspNetCore . ReDoc ;
@@ -219,8 +220,11 @@ public async Task ReDocMiddleware_Returns_ExpectedAssetContents_Decompressed()
219
220
Assert . Equal ( response . Content . Headers . ContentLength , actual . Length ) ;
220
221
}
221
222
222
- [ Fact ]
223
- public async Task ReDocMiddleware_Returns_ExpectedAssetContents_GZip_Compressed ( )
223
+ [ Theory ]
224
+ [ InlineData ( "gzip" ) ]
225
+ [ InlineData ( "gzip;q=1.0, identity; q=0.5, *;q=0" ) ]
226
+ [ InlineData ( "gzip, deflate, br, zstd" ) ]
227
+ public async Task ReDocMiddleware_Returns_ExpectedAssetContents_GZip_Compressed ( string acceptEncoding )
224
228
{
225
229
// Arrange
226
230
var cancellationToken = TestContext . Current . CancellationToken ;
@@ -229,7 +233,15 @@ public async Task ReDocMiddleware_Returns_ExpectedAssetContents_GZip_Compressed(
229
233
using var client = site . BuildClient ( ) ;
230
234
231
235
using var request = new HttpRequestMessage ( HttpMethod . Get , "/Api-Docs/redoc.standalone.js" ) ;
232
- request . Headers . AcceptEncoding . Add ( new ( "gzip" ) ) ;
236
+
237
+ var encodings = acceptEncoding . Split ( ',' )
238
+ . Select ( ( p ) => p . Trim ( ) )
239
+ . ToList ( ) ;
240
+
241
+ foreach ( var encoding in encodings )
242
+ {
243
+ request . Headers . AcceptEncoding . Add ( StringWithQualityHeaderValue . Parse ( encoding ) ) ;
244
+ }
233
245
234
246
// Act
235
247
using var response = await client . SendAsync ( request , cancellationToken ) ;
0 commit comments