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/*
|
src/main/resources/static/*
|
||||||
*.pcap
|
*.pcap
|
||||||
docker/postgres_data
|
data
|
||||||
|
|
||||||
HELP.md
|
HELP.md
|
||||||
.gradle
|
.gradle
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class LivePcapWorker extends AbstractPcapWorker {
|
|||||||
device = Pcaps.getDevByName(interfaceName);
|
device = Pcaps.getDevByName(interfaceName);
|
||||||
|
|
||||||
if(device == null) {
|
if(device == null) {
|
||||||
|
log.info("Existing devices: {}", Pcaps.findAllDevs().stream().map(PcapNetworkInterface::getName).toList());
|
||||||
throw new IllegalArgumentException("Device " + interfaceName + " does not exist");
|
throw new IllegalArgumentException("Device " + interfaceName + " does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.util.List;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class HttpChunksProcessor {
|
public class HttpChunksProcessor {
|
||||||
|
|
||||||
|
private static final String CHUNKED_HTTP_HEADER = "transfer-encoding: chunked\r\n";
|
||||||
private final List<Packet> packets;
|
private final List<Packet> packets;
|
||||||
|
|
||||||
private int position;
|
private int position;
|
||||||
@@ -38,7 +39,7 @@ public class HttpChunksProcessor {
|
|||||||
|
|
||||||
if (http && contentPos != -1) { // начало body
|
if (http && contentPos != -1) { // начало body
|
||||||
String headers = content.substring(0, contentPos + 2); // захватываем первые \r\n
|
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) {
|
if (chunked) {
|
||||||
chunkStarted = true;
|
chunkStarted = true;
|
||||||
start = position;
|
start = position;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.util.zip.ZipException;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class HttpGzipProcessor {
|
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 static final byte[] GZIP_HEADER = {0x1f, (byte) 0x8b, 0x08};
|
||||||
|
|
||||||
private final List<Packet> packets;
|
private final List<Packet> packets;
|
||||||
@@ -54,7 +55,7 @@ public class HttpGzipProcessor {
|
|||||||
|
|
||||||
if (contentPos != -1) { // начало body
|
if (contentPos != -1) { // начало body
|
||||||
String headers = content.substring(0, contentPos + 2); // захватываем первые \r\n
|
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) {
|
if (gziped) {
|
||||||
gzipStarted = true;
|
gzipStarted = true;
|
||||||
gzipStartPacket = position;
|
gzipStartPacket = position;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class HttpUrldecodeProcessor {
|
|||||||
|
|
||||||
if (httpStarted) {
|
if (httpStarted) {
|
||||||
try {
|
try {
|
||||||
content = URLDecoder.decode(content, StandardCharsets.UTF_8.toString());
|
content = URLDecoder.decode(content, StandardCharsets.UTF_8);
|
||||||
packet.setContent(content.getBytes());
|
packet.setContent(content.getBytes());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.warn("urldecode", e);
|
log.warn("urldecode", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user