Mercurial > stress-tester
changeset 1153:39588e98056b
HttpTrafficDumperFilter - username extraction improvements
author | Devel 2 |
---|---|
date | Fri, 12 Jun 2020 13:47:50 +0200 |
parents | a248b4a1a32f |
children | b03609639a1e |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpTrafficDumperFilter.java |
diffstat | 1 files changed, 27 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpTrafficDumperFilter.java Fri Jun 12 13:09:36 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpTrafficDumperFilter.java Fri Jun 12 13:47:50 2020 +0200 @@ -11,7 +11,9 @@ import com.passus.net.http.HttpRequest; import com.passus.net.http.HttpResponse; import com.passus.net.http.HttpStatus; +import com.passus.st.ParametersBag; import com.passus.st.client.FlowContext; +import com.passus.st.client.http.HttpFlowContext; import com.passus.st.emitter.SessionInfo; import com.passus.st.filter.FlowFilter; import com.passus.st.plugin.PluginConstants; @@ -25,6 +27,7 @@ import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; import static com.passus.net.http.HttpUtils.intToVersionString; import static com.passus.st.client.http.HttpConsts.*; +import static com.passus.st.client.http.filter.HttpFlowUtils.extractHttpContext; import static com.passus.st.config.CommonNodeDefs.STRING_DEF; @NodeDefinitionCreate(HttpTrafficDumperFilter.HttpSessionCookieFilterNodeDefCreator.class) @@ -177,8 +180,17 @@ HttpHeaders respHeaders = resp.getHeaders(); writeString(respHeaders.get(HttpHeaders.CONTENT_TYPE)); - write(resp.getTag(TAG_TIME_START)); - write(resp.getTag(TAG_TIME_END)); + + Long timeStart = (Long) resp.getTag(TAG_TIME_START); + Long timeEnd = (Long) resp.getTag(TAG_TIME_END); + + if (timeStart != null && timeStart == -1 + && timeEnd != null && timeEnd != -1) { + timeStart = timeEnd; + } + + write(timeStart); + write(timeEnd); write(resp.getTag(TAG_HEADER_SIZE)); if (resp.hasContent()) { @@ -197,7 +209,19 @@ } write(req.getTag(TAG_SESSION_ID)); - write(req.getTag(TAG_USERNAME)); + + HttpFlowContext httpFlowContext = extractHttpContext(context); + if (httpFlowContext != null) { + ParametersBag session = httpFlowContext.scopes().getSession(req, false); + if (session != null) { + write(session.get(PARAM_USERNAME)); + } else { + writeString(""); + } + } else { + writeString(""); + } + csvHelper.write(context.loop(), writer); csvHelper.write("\n", writer); }