Mercurial > stress-tester
changeset 469:ef2c26e83b32
minor
author | Devel 1 |
---|---|
date | Thu, 03 Aug 2017 14:41:07 +0200 |
parents | 39b770911027 |
children | a9862e2aacaa |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersFilterCleaner.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java |
diffstat | 3 files changed, 53 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersCleanerFilter.java Thu Aug 03 14:41:07 2017 +0200 @@ -0,0 +1,52 @@ +package com.passus.st.client.http.filter; + +import com.passus.commons.annotations.Plugin; +import com.passus.data.ByteString; +import com.passus.net.http.HttpHeaders; +import com.passus.net.http.HttpRequest; +import com.passus.net.http.HttpResponse; +import com.passus.st.client.http.HttpFlowContext; +import com.passus.st.plugin.PluginConstants; +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author Mirosław Hawrot + */ +@Plugin(name = HttpRequestProxyHeadersCleanerFilter.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) +public class HttpRequestProxyHeadersCleanerFilter extends HttpFilter { + + public static final String TYPE = "requestProxyHeadersCleaner"; + + public static final ByteString[] PROXY_HEADERS; + + static { + Set<ByteString> reqProxyHeaders = new HashSet<>(); + reqProxyHeaders.add(ByteString.create("Forwarded")); + reqProxyHeaders.add(ByteString.create("Proxy-Authorization")); + reqProxyHeaders.add(ByteString.create("X-Forwarded-For")); + reqProxyHeaders.add(ByteString.create("X-Forwarded-Host")); + reqProxyHeaders.add(ByteString.create("X-Forwarded-Proto")); + reqProxyHeaders.add(ByteString.create("Proxy-Connection")); + PROXY_HEADERS = reqProxyHeaders.toArray(new ByteString[]{}); + } + + @Override + public int filterOutbound(HttpRequest request, HttpResponse resp, HttpFlowContext context) { + if (request != null) { + HttpHeaders headers = request.getHeaders(); + for (ByteString headerName : PROXY_HEADERS) { + headers.delete(headerName); + } + } + + return DUNNO; + } + + @Override + public HttpRequestProxyHeadersCleanerFilter instanceForWorker(int index) { + return new HttpRequestProxyHeadersCleanerFilter(); + } + +}
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpRequestProxyHeadersFilterCleaner.java Thu Aug 03 11:51:08 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -package com.passus.st.client.http.filter; - -import com.passus.commons.annotations.Plugin; -import com.passus.data.ByteString; -import com.passus.net.http.HttpHeaders; -import com.passus.net.http.HttpRequest; -import com.passus.net.http.HttpResponse; -import com.passus.st.client.http.HttpFlowContext; -import com.passus.st.plugin.PluginConstants; -import java.util.HashSet; -import java.util.Set; - -/** - * - * @author Mirosław Hawrot - */ -@Plugin(name = HttpRequestProxyHeadersFilterCleaner.TYPE, category = PluginConstants.CATEGORY_HTTP_FILTER) -public class HttpRequestProxyHeadersFilterCleaner extends HttpFilter { - - public static final String TYPE = "requestProxyHeadersCleaner"; - - public static final ByteString[] PROXY_HEADERS; - - static { - Set<ByteString> reqProxyHeaders = new HashSet<>(); - reqProxyHeaders.add(ByteString.create("Forwarded")); - reqProxyHeaders.add(ByteString.create("Proxy-Authorization")); - reqProxyHeaders.add(ByteString.create("X-Forwarded-For")); - reqProxyHeaders.add(ByteString.create("X-Forwarded-Host")); - reqProxyHeaders.add(ByteString.create("X-Forwarded-Proto")); - reqProxyHeaders.add(ByteString.create("Proxy-Connection")); - PROXY_HEADERS = reqProxyHeaders.toArray(new ByteString[]{}); - } - - @Override - public int filterOutbound(HttpRequest request, HttpResponse resp, HttpFlowContext context) { - if (request != null) { - HttpHeaders headers = request.getHeaders(); - for (ByteString headerName : PROXY_HEADERS) { - headers.delete(headerName); - } - } - - return DUNNO; - } - - @Override - public HttpRequestProxyHeadersFilterCleaner instanceForWorker(int index) { - return new HttpRequestProxyHeadersFilterCleaner(); - } - -}
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Thu Aug 03 11:51:08 2017 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java Thu Aug 03 14:41:07 2017 +0200 @@ -40,7 +40,7 @@ HttpMessageModificationFilter modFilter = (HttpMessageModificationFilter) filters.get(0); assertEquals(6, modFilter.getOperations().size()); - assertTrue(filters.get(1) instanceof HttpRequestProxyHeadersFilterCleaner); + assertTrue(filters.get(1) instanceof HttpRequestProxyHeadersCleanerFilter); assertTrue(filters.get(2) instanceof HttpBasicAuthLoginFilter); HttpBasicAuthLoginFilter basicAuthLoginFilter = (HttpBasicAuthLoginFilter) filters.get(2);