Fix an issue with lowercase http headers
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,6 @@
|
||||
src/main/resources/static/*
|
||||
*.pcap
|
||||
docker/postgres_data
|
||||
data
|
||||
|
||||
HELP.md
|
||||
.gradle
|
||||
|
||||
@@ -27,6 +27,7 @@ public class LivePcapWorker extends AbstractPcapWorker {
|
||||
device = Pcaps.getDevByName(interfaceName);
|
||||
|
||||
if(device == null) {
|
||||
log.info("Existing devices: {}", Pcaps.findAllDevs().stream().map(PcapNetworkInterface::getName).toList());
|
||||
throw new IllegalArgumentException("Device " + interfaceName + " does not exist");
|
||||
}
|
||||
|
||||
|
||||
@@ -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