Mercurial > stress-tester
changeset 788:c237fae692f1
bugfix
author | Devel 1 |
---|---|
date | Wed, 20 Dec 2017 13:24:56 +0100 |
parents | e400b2e6d698 |
children | 595f1081548e |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpVarsFilter.java stress-tester/src/main/java/com/passus/st/vars/HttpVarsFilter.java |
diffstat | 2 files changed, 1 insertions(+), 73 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpVarsFilter.java Wed Dec 20 12:53:30 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpVarsFilter.java Wed Dec 20 13:24:56 2017 +0100 @@ -49,7 +49,7 @@ @Override public HttpFilter instanceForWorker(int index) { - return new HttpVarsFilter(); + return new HttpVarsFilter(compiler, executor); } @Override
--- a/stress-tester/src/main/java/com/passus/st/vars/HttpVarsFilter.java Wed Dec 20 12:53:30 2017 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -package com.passus.st.vars; - -import com.passus.commons.Assert; -import com.passus.data.ByteBuff; -import com.passus.data.HeapByteBuff; -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 com.passus.st.client.http.filter.HttpFilter; -import com.passus.st.client.http.filter.HttpMessageWrapper; -import java.io.IOException; -import java.util.List; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * - * @author Mirosław Hawrot - */ -public class HttpVarsFilter extends HttpFilter { - - private static final Logger LOGGER = LogManager.getLogger(HttpVarsFilter.class); - - private final HttpMessageHelper helper = HttpMessageHelper.get(); - - private final VarsCompiler compiler; - - private final VarsExecutor executor; - - public HttpVarsFilter() { - compiler = new VarsCompiler(); - executor = new VarsExecutor(); - } - - public HttpVarsFilter(VarsCompiler compiler, VarsExecutor executor) { - Assert.notNull(compiler, "compiler"); - Assert.notNull(executor, "executor"); - this.compiler = compiler; - this.executor = executor; - } - - @Override - public HttpFilter instanceForWorker(int index) { - return new HttpVarsFilter(); - } - - @Override - public int filterOutbound(HttpRequest req, HttpResponse resp, HttpFlowContext context) { - //Przetwarzamy tylko requesty, response'a nie ma sensu - if (req != null) { - try { - helper.decodeContent(req, true); - ByteBuff buffer = req.getContentByteBuff(); - if (buffer != null) { - List<Var> vars = compiler.search(buffer); - if (vars != null && !vars.isEmpty()) { - ByteBuff result = new HeapByteBuff(buffer.readableBytes()); - executor.execute(buffer, result, vars, new HttpMessageWrapper(req, resp, context)); - } - } - } catch (IOException e) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug(e.getMessage(), e); - } - } - } - - return DUNNO; - } - -}