Author: pmouawad Date: Fri Oct 27 12:54:39 2017 New Revision: 1813529 URL: http://svn.apache.org/viewvc?rev=1813529&view=rev Log: Bug 57760 - View Results Tree : Cookie Header is wrongly shown as empty(no cookies) when viewing a recorder Sample Result Fix issue in Cookie extraction from Header Add TestCookieManager.jmx to build
Bugzilla Id: 57760 Modified: jmeter/trunk/build.xml jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java Modified: jmeter/trunk/build.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/build.xml?rev=1813529&r1=1813528&r2=1813529&view=diff ============================================================================== --- jmeter/trunk/build.xml (original) +++ jmeter/trunk/build.xml Fri Oct 27 12:54:39 2017 @@ -2737,6 +2737,11 @@ run JMeter unless all the JMeter jars ar </antcall> <antcall target="batchtest"> + <param name="batchtest.name" value="TestCookieManager"/> + <param name="batchtest.jmx" value="TestCookieManager.jmx"/> + </antcall> + + <antcall target="batchtest"> <param name="batchtest.name" value="TCP_TESTS"/> <param name="batchtest.jmx" value="TCP_TESTS.jmx"/> <param name="batchtest.ignoreErrorLogs" value="true" /> Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1813529&r1=1813528&r2=1813529&view=diff ============================================================================== --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original) +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Fri Oct 27 12:54:39 2017 @@ -1170,7 +1170,11 @@ public class HTTPHC4Impl extends HTTPHCA * @return the headers as a string */ private String getOnlyCookieFromHeaders(HttpRequest method) { - return getFromHeadersMatchingPredicate(method, ONLY_COOKIE); + String cookieHeader= getFromHeadersMatchingPredicate(method, ONLY_COOKIE).trim(); + if(!cookieHeader.isEmpty()) { + return cookieHeader.substring((HTTPConstants.HEADER_COOKIE_IN_REQUEST).length(), cookieHeader.length()).trim(); + } + return ""; } Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java?rev=1813529&r1=1813528&r2=1813529&view=diff ============================================================================== --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java (original) +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java Fri Oct 27 12:54:39 2017 @@ -404,7 +404,11 @@ public class HTTPJavaImpl extends HTTPAb * @return the headers as a string */ private String getOnlyCookieFromHeaders(HttpURLConnection conn, Map<String, String> securityHeaders) { - return getFromConnectionHeaders(conn, securityHeaders, ONLY_COOKIE, false); + String cookieHeader= getFromConnectionHeaders(conn, securityHeaders, ONLY_COOKIE, false).trim(); + if(!cookieHeader.isEmpty()) { + return cookieHeader.substring((HTTPConstants.HEADER_COOKIE_IN_REQUEST).length(), cookieHeader.length()).trim(); + } + return ""; } /** Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java?rev=1813529&r1=1813528&r2=1813529&view=diff ============================================================================== --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java (original) +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HTTPConstantsInterface.java Fri Oct 27 12:54:39 2017 @@ -56,6 +56,7 @@ public interface HTTPConstantsInterface String SEARCH = "SEARCH"; // $NON-NLS-1$ String HEADER_AUTHORIZATION = "Authorization"; // $NON-NLS-1$ String HEADER_COOKIE = "Cookie"; // $NON-NLS-1$ + String HEADER_COOKIE_IN_REQUEST = "Cookie:"; // $NON-NLS-1$ String HEADER_CONNECTION = "Connection"; // $NON-NLS-1$ String CONNECTION_CLOSE = "close"; // $NON-NLS-1$ String KEEP_ALIVE = "keep-alive"; // $NON-NLS-1$