You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by JTM <jm...@llbean.com> on 2015/03/20 20:26:50 UTC

how to capture 301 redirect responses in results CSV file

Hi
Noob here. My first jMeter task is to validate URLs. It's going very well
and have some assertions in place capturing things like "results=0" on
search pages. However, I am unable to figure out how to ensure the initial
301 redirect response is written to our CSV results file.

As an example, the 2nd row below is the followed location after the redirect
occurs:

URL Testing,200,OK,JMeter Users
1-1,text,true,,53031,1,1,http://www.xyz.com/,,82,1,0
URL Testing,200,OK,JMeter Users
1-1,text,true,,308058,1,1,*http://www.xyz.com/blog*,,179,1,0

... what I'd like to have, is the 301 redirect response written to the
results file, so, a new row 2 example might look like this ...  

URL Testing,200,OK,,text,true,,53031,1,1,http://www.xyz.com/,,82,1,0
URL
Testing,*301*,OK,,text,true,,53031,1,1,http://www.xyz.com/articles,,82,1,0
URL Testing,200,OK,,text,true,,308058,1,1,*http://www.xyz.com/blog*,,179,1,0

Any ideas on how I can capture the 301 response in the results file
appreciated. 

thanks



--
View this message in context: http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: how to capture 301 redirect responses in results CSV file

Posted by JTM <jm...@llbean.com>.
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: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: how to capture 301 redirect responses in results CSV file

Posted by JTM <jm...@llbean.com>.
Or you can use XML output in conjunction with Follow Redirect.
This will show the original redirect response and the subsequent 200
response as parts of a parent sample.
CSV files only show the parent sample.


XML is giving me what I need. I may post-process the result with Perl to get
the final CSV results format I need.

thanks





--
View this message in context: http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974p5721996.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: how to capture 301 redirect responses in results CSV file

Posted by sebb <se...@gmail.com>.
Or you can use XML output in conjunction with Follow Redirect.
This will show the original redirect response and the subsequent 200
response as parts of a parent sample.
CSV files only show the parent sample.

On 20 March 2015 at 22:15, Sergio Boso <se...@bosoconsulting.it> wrote:
> Hi,
>
> you also need to apply some regex to the response header, in order to
> extract the URL to a suitable variable, and use it in the following sampler.
> Regards
>
> Sergio Boso
> Il 20/Mar/2015 21:08 "JTM" <jm...@llbean.com> ha scritto:
>
>> So that does let the 301 redirect get recorded in the result CSV file, but
>> then I lose the following row for the response with the redirected
>> Location.
>>
>> So for example, when /articles  gets redirected to /blog I'd like both
>> responses captured. Something like this would be my desired results CSV . .
>> .
>>
>> URL Testing,301,OK,,text,true,,53031,1,1,
>> http://www.xyz.com/articles,,82,1,0
>> URL Testing,200,OK,,text,true,,308058,1,1,http://www.xyz.com/blog,,179,1,0
>>
>> When I shut off Follow Redirects, I get only the 301 displayed, but want
>> both the 301 and the following response(s).
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974p5721976.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: how to capture 301 redirect responses in results CSV file

Posted by Sergio Boso <se...@bosoconsulting.it>.
Hi,

you also need to apply some regex to the response header, in order to
extract the URL to a suitable variable, and use it in the following sampler.
Regards

Sergio Boso
Il 20/Mar/2015 21:08 "JTM" <jm...@llbean.com> ha scritto:

> So that does let the 301 redirect get recorded in the result CSV file, but
> then I lose the following row for the response with the redirected
> Location.
>
> So for example, when /articles  gets redirected to /blog I'd like both
> responses captured. Something like this would be my desired results CSV . .
> .
>
> URL Testing,301,OK,,text,true,,53031,1,1,
> http://www.xyz.com/articles,,82,1,0
> URL Testing,200,OK,,text,true,,308058,1,1,http://www.xyz.com/blog,,179,1,0
>
> When I shut off Follow Redirects, I get only the 301 displayed, but want
> both the 301 and the following response(s).
>
>
>
>
>
> --
> View this message in context:
> http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974p5721976.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: how to capture 301 redirect responses in results CSV file

Posted by JTM <jm...@llbean.com>.
So that does let the 301 redirect get recorded in the result CSV file, but
then I lose the following row for the response with the redirected Location.

So for example, when /articles  gets redirected to /blog I'd like both
responses captured. Something like this would be my desired results CSV . .
. 

URL Testing,301,OK,,text,true,,53031,1,1,http://www.xyz.com/articles,,82,1,0
URL Testing,200,OK,,text,true,,308058,1,1,http://www.xyz.com/blog,,179,1,0

When I shut off Follow Redirects, I get only the 301 displayed, but want
both the 301 and the following response(s).





--
View this message in context: http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974p5721976.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: how to capture 301 redirect responses in results CSV file

Posted by sebb <se...@gmail.com>.
On 20 March 2015 at 19:26, JTM <jm...@llbean.com> wrote:
> Hi
> Noob here. My first jMeter task is to validate URLs. It's going very well
> and have some assertions in place capturing things like "results=0" on
> search pages. However, I am unable to figure out how to ensure the initial
> 301 redirect response is written to our CSV results file.

Since 301 is a redirect, you need to switch off automatic redirects.

> As an example, the 2nd row below is the followed location after the redirect
> occurs:
>
> URL Testing,200,OK,JMeter Users
> 1-1,text,true,,53031,1,1,http://www.xyz.com/,,82,1,0
> URL Testing,200,OK,JMeter Users
> 1-1,text,true,,308058,1,1,*http://www.xyz.com/blog*,,179,1,0
>
> ... what I'd like to have, is the 301 redirect response written to the
> results file, so, a new row 2 example might look like this ...
>
> URL Testing,200,OK,,text,true,,53031,1,1,http://www.xyz.com/,,82,1,0
> URL
> Testing,*301*,OK,,text,true,,53031,1,1,http://www.xyz.com/articles,,82,1,0
> URL Testing,200,OK,,text,true,,308058,1,1,*http://www.xyz.com/blog*,,179,1,0
>
> Any ideas on how I can capture the 301 response in the results file
> appreciated.
>
> thanks
>
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/how-to-capture-301-redirect-responses-in-results-CSV-file-tp5721974.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org