Wanted to circle back and note that we were able to capture 301 redirects, and have them embedded into the CSV - without having to fallback to using an XML output. Which will save a step from post-processing the XML.
Using a BSF Postprocessor, using Javascript, we can obtain the previous sample row, grab response code and URL, and output to the Message field, yielding rows such as this: 200,,,http://www.xyz.com/, 200,301|http://www.xyz.com/llb/search/?text=Coats,,http://www.xyz.com/shop/3322, Note the 2nd row has the 200 response for the followed/redirected URL, with the original request and it's 301 response code embedded. Here is a screenshot of the Post Processor code ... <http://jmeter.512774.n5.nabble.com/file/n5722015/BSFPostProcessor.jpg> Also, here is the JS code from the BSF Input form in case you have trouble with the image. ______________________________________________ • subresponse = prev.getSubResults() ; // returns an array of responses, e.g., a 301 and then a 200 • var str = ''; • for ( var i=0; i < subresponse.length; i++){ • if( subresponse[i].getResponseCode() == '301' ){ • str += subresponse[i].getResponseCode() +"|"+ subresponse[i].getUrlAsString(); • } • } • prev.setResponseMessage(str); // insert to the CVS output . . . ______________________________________________ Just wanted to let others know this is an option. I had help from a co-worker, who pointed me to this page for methods in accessing a Sample. https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html HTH -- View this message in context: http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974p5722015.html Sent from the JMeter - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
