Mercurial > stress-tester
changeset 815:a58bbf4ee5e6
minor
author | Devel 1 |
---|---|
date | Tue, 16 Jan 2018 15:49:22 +0100 |
parents | f27093f7af45 |
children | 2fb899e95c4b |
files | stress-tester/src/main/java/com/passus/st/PcapScanner.java |
diffstat | 1 files changed, 32 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/PcapScanner.java Mon Jan 15 15:08:59 2018 +0100 +++ b/stress-tester/src/main/java/com/passus/st/PcapScanner.java Tue Jan 16 15:49:22 2018 +0100 @@ -1,6 +1,10 @@ package com.passus.st; +import com.passus.data.ByteString; +import com.passus.net.http.HttpHeaders; import com.passus.net.http.HttpMessage; +import com.passus.net.http.HttpMethod; +import com.passus.net.http.HttpRequest; import com.passus.net.http.URL; import static com.passus.st.Main.printHelp; import com.passus.st.client.Event; @@ -76,6 +80,25 @@ public Object extract(HttpSessionPayloadEvent event); } + static class PostExtractor implements Extractor { + + @Override + public Object extract(HttpSessionPayloadEvent event) { + HttpRequest request = event.getRequest(); + ByteString contentTypeBs = request.getHeaders().get(HttpHeaders.CONTENT_TYPE); + HttpMethod method = request.getMethod(); + + if (HttpMethod.POST.equals(method) && contentTypeBs != null) { + String contentType = contentTypeBs.toString(); + if (contentType.equals("application/x-www-form-urlencoded")) { + return request; + } + } + return null; + } + + } + public interface URLExtractor { public Object extract(URL url); @@ -92,18 +115,19 @@ options.addOption(option("l", "logLevel").desc("Log level.") .hasArg().argName("level") - .build() - ); + .build()); options.addOption(option("ips", "ignorePartialSession").desc("Ignore partial sessions.") .hasArg(false) - .build() - ); + .build()); options.addOption(option("e", "extractor").desc("Extraction expression, default " + DEFAULT_EXTRACTOR) .hasArg().argName("expression") - .build() - ); + .build()); + + options.addOption(option("hp", "httpPorts").desc("Specify HTTP ports in input file (default: 80, 8080)") + .hasArg().argName("ports") + .build()); try { CommandLine cl = new DefaultParser().parse(options, args); @@ -174,6 +198,8 @@ return (e) -> urlExtract(e, (URL url) -> url.getQuery()); // case "header": //TODO + case "reqPost": + return new PostExtractor(); case "reqHdr": return (e) -> e.getRequest().getHeaders().get(arg); case "respHdr":