Mercurial > stress-tester
changeset 747:a86bd0a170ad
HttpContentDecodingFilter
author | Devel 2 |
---|---|
date | Fri, 08 Dec 2017 13:52:21 +0100 |
parents | 05758e673530 |
children | 92a55d662870 |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpContentDecodingFilter.java |
diffstat | 1 files changed, 45 insertions(+), 0 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/HttpContentDecodingFilter.java Fri Dec 08 13:52:21 2017 +0100 @@ -0,0 +1,45 @@ +package com.passus.st.client.http.filter; + +import com.passus.net.http.HttpMessage; +import com.passus.net.http.HttpMessageHelper; +import com.passus.net.http.HttpRequest; +import com.passus.net.http.HttpResponse; +import com.passus.st.client.http.HttpFlowContext; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * + * @author Mirosław Hawrot + */ +public class HttpContentDecodingFilter extends HttpFilter { + + private static final Logger LOGGER = LogManager.getLogger(HttpContentDecodingFilter.class); + + private final HttpMessageHelper helper = HttpMessageHelper.get(); + + private void encodeMessageContent(HttpMessage msg) { + if (msg == null) { + return; + } + + try { + helper.decodeContent(msg); + } catch (Exception e) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(e.getMessage(), e); + } + } + } + + @Override + public int filterOutbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { + encodeMessageContent(req); + return DUNNO; + } + + @Override + public HttpFilter instanceForWorker(int index) { + return new HttpContentDecodingFilter(); + } +}