Mercurial > stress-tester
changeset 455:c9f06c2ca729
HttpMessageWrapper
author | Devel 2 |
---|---|
date | Tue, 01 Aug 2017 12:24:47 +0200 |
parents | 8c8853c216fe |
children | f9515c48d331 |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMatchFilter.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageWrapper.java |
diffstat | 3 files changed, 77 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java Tue Aug 01 10:42:12 2017 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpAbstractLoginFilter.java Tue Aug 01 12:24:47 2017 +0200 @@ -18,7 +18,6 @@ import com.passus.st.client.credentials.CredentialsProviderFactory; import com.passus.st.client.credentials.MultiCredentialsProviderTransformer; import com.passus.st.client.http.HttpFlowContext; -import com.passus.st.client.http.filter.HttpMessagePredicate.HttpMessageWrapper; import java.util.Collection; /**
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMatchFilter.java Tue Aug 01 10:42:12 2017 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMatchFilter.java Tue Aug 01 12:24:47 2017 +0200 @@ -54,7 +54,7 @@ return DUNNO; } - boolean match = predicate.test(new HttpMessagePredicate.HttpMessageWrapper(request, resp, context)); + boolean match = predicate.test(new HttpMessageWrapper(request, resp, context)); if (!match) { return DUNNO;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageWrapper.java Tue Aug 01 12:24:47 2017 +0200 @@ -0,0 +1,76 @@ +package com.passus.st.client.http.filter; + +import com.passus.net.http.HttpMessage; +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.HttpScopes; +import com.passus.st.emitter.SessionInfo; + +/** + * + * @author Mirosław Hawrot + */ +public class HttpMessageWrapper { + + private final HttpFilterRequestWrapper req; + + private final HttpFilterResponseWrapper resp; + + private final HttpFilterResponseWrapper origResp; + + private final HttpFlowContext context; + + public HttpMessageWrapper(HttpRequest req, HttpResponse resp, HttpFlowContext context) { + this.req = (HttpFilterRequestWrapper) createWrapper((HttpRequest) req); + this.resp = (HttpFilterResponseWrapper) createWrapper((HttpResponse) resp); + + if (context != null) { + this.origResp = (HttpFilterResponseWrapper) createWrapper((HttpResponse) context.origReponse()); + this.context = context; + } else { + this.context = null; + this.origResp = null; + } + } + + public HttpFilterRequestWrapper getReq() { + return req; + } + + public HttpFilterResponseWrapper getResp() { + return resp; + } + + public HttpFilterResponseWrapper getOrigResp() { + return origResp; + } + + public SessionInfo getSession() { + if (context != null) { + return context.sessionInfo(); + } + return null; + } + + public HttpScopes getScopes() { + if (context != null) { + return context.scopes(); + } + + return null; + } + + private HttpFilterMessageWrapper createWrapper(HttpMessage message) { + if (message == null) { + return null; + } + + if (message.isRequest()) { + return new HttpFilterRequestWrapper((HttpRequest) message); + } else { + return new HttpFilterResponseWrapper((HttpResponse) message); + } + } + +}