Mercurial > stress-tester
changeset 610:299e971b600a
ST-92
author | Devel 1 |
---|---|
date | Mon, 09 Oct 2017 12:55:52 +0200 |
parents | 53d0d102a8b5 |
children | d3c6e21084cd |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionCookieFilter.java |
diffstat | 1 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionCookieFilter.java Mon Oct 09 11:49:13 2017 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSessionCookieFilter.java Mon Oct 09 12:55:52 2017 +0200 @@ -54,7 +54,14 @@ * Maps SID from input file to SID from live communication. */ private final Map<ByteString, ByteString> cookiesMap = new ConcurrentHashMap<>(); - private final HttpMessageHelper helper = HttpMessageHelper.NOT_STRICT; + + private static final ThreadLocal<HttpMessageHelper> HELPER = new ThreadLocal<HttpMessageHelper>() { + @Override + protected HttpMessageHelper initialValue() { + return new HttpMessageHelper(false); + } + }; + private boolean removeInvalidSessionId = false; public HttpSessionCookieFilter() { @@ -95,7 +102,7 @@ HttpCookie sessionCookie = null; for (CharSequence cookieName : cookieNames) { - sessionCookie = helper.getCookie(msg, cookieName); + sessionCookie = HELPER.get().getCookie(msg, cookieName); if (sessionCookie != null) { break; } @@ -123,15 +130,17 @@ ByteString liveValue = cookiesMap.get(inValue); if (liveValue != null) { String sessionId = liveValue.toString(); - helper.updateCookieValue(pcapRequest, requestCookie.getName(), liveValue); + HELPER.get().updateCookieValue(pcapRequest, requestCookie.getName(), liveValue); LOGGER.debug("Mapping used {} -> {} [{}]", inValue, liveValue, pcapRequest.getUrl()); setTag(pcapRequest, TAG_SESSION_ID, sessionId); setTag(pcapResponse, TAG_SESSION_ID, sessionId); - } else if (removeInvalidSessionId) { - helper.removeCookie(pcapRequest, requestCookie.getName()); - LOGGER.debug("No mapping for {} [{}]", inValue, pcapRequest.getUrl()); } else { - setTag(pcapRequest, TAG_SESSION_ID, requestCookie.getValue().toString()); + LOGGER.debug("Mapping not found for {} [{}]", inValue, pcapRequest.getUrl()); + if (removeInvalidSessionId) { + HELPER.get().removeCookie(pcapRequest, requestCookie.getName()); + } else { + setTag(pcapRequest, TAG_SESSION_ID, requestCookie.getValue().toString()); + } } }