Fix an issue with lowercase http headers
This commit is contained in:
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class HttpChunksProcessor {
|
||||
|
||||
private static final String CHUNKED_HTTP_HEADER = "transfer-encoding: chunked\r\n";
|
||||
private final List<Packet> packets;
|
||||
|
||||
private int position;
|
||||
@@ -38,7 +39,7 @@ public class HttpChunksProcessor {
|
||||
|
||||
if (http && contentPos != -1) { // начало body
|
||||
String headers = content.substring(0, contentPos + 2); // захватываем первые \r\n
|
||||
boolean chunked = headers.contains("Transfer-Encoding: chunked\r\n");
|
||||
boolean chunked = headers.toLowerCase().contains(CHUNKED_HTTP_HEADER);
|
||||
if (chunked) {
|
||||
chunkStarted = true;
|
||||
start = position;
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.zip.ZipException;
|
||||
@RequiredArgsConstructor
|
||||
public class HttpGzipProcessor {
|
||||
|
||||
private static final String GZIP_HTTP_HEADER = "content-encoding: gzip\r\n";
|
||||
private static final byte[] GZIP_HEADER = {0x1f, (byte) 0x8b, 0x08};
|
||||
|
||||
private final List<Packet> packets;
|
||||
@@ -54,7 +55,7 @@ public class HttpGzipProcessor {
|
||||
|
||||
if (contentPos != -1) { // начало body
|
||||
String headers = content.substring(0, contentPos + 2); // захватываем первые \r\n
|
||||
boolean gziped = headers.contains("Content-Encoding: gzip\r\n");
|
||||
boolean gziped = headers.toLowerCase().contains(GZIP_HTTP_HEADER);
|
||||
if (gziped) {
|
||||
gzipStarted = true;
|
||||
gzipStartPacket = position;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class HttpUrldecodeProcessor {
|
||||
|
||||
if (httpStarted) {
|
||||
try {
|
||||
content = URLDecoder.decode(content, StandardCharsets.UTF_8.toString());
|
||||
content = URLDecoder.decode(content, StandardCharsets.UTF_8);
|
||||
packet.setContent(content.getBytes());
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("urldecode", e);
|
||||
|
||||
Reference in New Issue
Block a user