Skip to content

Commit 82a97a8

Browse files
committed
Cleanup
1 parent 22cf7d8 commit 82a97a8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/main/java/io/fusionauth/http/server/HTTPRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,8 @@ private void decodeHeader(String name, String value) {
790790
continue;
791791
}
792792

793-
// The HTTP/1.1 standard recommends that the servers supporting gzip also recognize x-gzip as an alias, for compatibility purposes.
794-
if (encoding.equals(ContentEncodings.XGzip)) {
793+
// The HTTP/1.1 standard recommends that the servers supporting gzip also recognize x-gzip as an alias for compatibility.
794+
if (encoding.equalsIgnoreCase(ContentEncodings.XGzip)) {
795795
encoding = ContentEncodings.Gzip;
796796
}
797797

src/test/java/io/fusionauth/http/CompressionTest.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.testng.annotations.DataProvider;
4141
import org.testng.annotations.Test;
4242
import static org.testng.Assert.assertEquals;
43+
import static org.testng.Assert.assertNotEquals;
4344
import static org.testng.Assert.assertNotNull;
4445
import static org.testng.Assert.assertNull;
4546
import static org.testng.AssertJUnit.fail;
@@ -258,14 +259,17 @@ public void compressWithContentLength(String scheme) throws Exception {
258259

259260
assertEquals(req.isChunked(), false);
260261

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
265265
var contentLength = req.getHeader(Headers.ContentLength);
266266
assertEquals(contentLength, payload.length + "");
267267

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);
269273
assertEquals(body, bodyString);
270274

271275
res.setHeader(Headers.ContentType, "text/plain");
@@ -326,9 +330,9 @@ public Object[][] compressedChunkedSchemes() {
326330
{"deflate, gzip", "deflate, gzip"},
327331
{"gzip, deflate", "gzip, deflate"},
328332

329-
// x-gzip alias, https
333+
// x-gzip with mixed case alias, https
330334
{"x-gzip", "deflate, gzip"},
331-
{"x-gzip, deflate", "gzip, deflate"},
335+
{"X-Gzip, deflate", "gzip, deflate"},
332336
{"deflate, x-gzip", "gzip, deflate"},
333337
};
334338

0 commit comments

Comments
 (0)