|
40 | 40 | import org.testng.annotations.DataProvider; |
41 | 41 | import org.testng.annotations.Test; |
42 | 42 | import static org.testng.Assert.assertEquals; |
| 43 | +import static org.testng.Assert.assertNotEquals; |
43 | 44 | import static org.testng.Assert.assertNotNull; |
44 | 45 | import static org.testng.Assert.assertNull; |
45 | 46 | import static org.testng.AssertJUnit.fail; |
@@ -258,14 +259,17 @@ public void compressWithContentLength(String scheme) throws Exception { |
258 | 259 |
|
259 | 260 | assertEquals(req.isChunked(), false); |
260 | 261 |
|
261 | | - // We forced a Content-Length by telling the JDK client not to chunk, so it will be present. It will |
262 | | - // be used in theory - and it should be ok as long as we are using it to count compressed bytes? |
263 | | - // TODO : Once I add the push back tests for compression, we'll see if this still works. We may |
264 | | - // need to manually remove the Content-Length header when we know the body to be compressed. |
| 262 | + // We forced a Content-Length by telling the JDK client not to chunk, so it will be present. |
| 263 | + // - We can still correctly use the Content-Length because it is used by the FixedLengthInputStream which |
| 264 | + // is below the decompression. See HTTPInputStream.initialize |
265 | 265 | var contentLength = req.getHeader(Headers.ContentLength); |
266 | 266 | assertEquals(contentLength, payload.length + ""); |
267 | 267 |
|
268 | | - String body = new String(req.getInputStream().readAllBytes()); |
| 268 | + // Because we are compressed, don't expect the final payload to be equal to the contentLength |
| 269 | + byte[] readBytes = req.getInputStream().readAllBytes(); |
| 270 | + assertNotEquals(readBytes.length, contentLength); |
| 271 | + |
| 272 | + String body = new String(readBytes); |
269 | 273 | assertEquals(body, bodyString); |
270 | 274 |
|
271 | 275 | res.setHeader(Headers.ContentType, "text/plain"); |
@@ -326,9 +330,9 @@ public Object[][] compressedChunkedSchemes() { |
326 | 330 | {"deflate, gzip", "deflate, gzip"}, |
327 | 331 | {"gzip, deflate", "gzip, deflate"}, |
328 | 332 |
|
329 | | - // x-gzip alias, https |
| 333 | + // x-gzip with mixed case alias, https |
330 | 334 | {"x-gzip", "deflate, gzip"}, |
331 | | - {"x-gzip, deflate", "gzip, deflate"}, |
| 335 | + {"X-Gzip, deflate", "gzip, deflate"}, |
332 | 336 | {"deflate, x-gzip", "gzip, deflate"}, |
333 | 337 | }; |
334 | 338 |
|
|
0 commit comments