You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Beth Schrag <be...@breaktech.com> on 2020/11/18 17:46:39 UTC

CORS Redirect in JMeter

Hello,
I have a CORS-related question: Has anyone found a way to get JMeter to follow a redirect of a GET request by first sending an OPTIONS request with the appropriate CORS-related headers (Origin, Access-Control-Request-Headers, and Access-Control-Request-Method), followed by a GET request to the redirected URL?

It seems that JMeter doesn’t send the proper CORS-related headers on it’s own.

[cidimage001.jpg@01D698C9.3E168500]<http://www.breaktech.com/>
Beth Schrag
Software Engineer
C: 847.363.7306
Breakthrough Technologies LLC
General:847.864.0033
Visit us at breaktech.com<http://www.breaktech.com/>
[cidimage003.jpg@01D698C9.3E168500]<https://www.linkedin.com/company/breakthrough-technologies> [cidimage005.jpg@01D698C9.3E168500] <https://twitter.com/break_tech>  [cidimage007.jpg@01D698C9.3E168500] <https://www.facebook.com/Breakthrough-Technologies-282856188427598/>

Confidential information may be contained in this message. If you are not the addressee indicated in the message, you should destroy this message. @2020 Breakthrough Technologies, LLC.


Re: CORS Redirect in JMeter

Posted by Beth Schrag <be...@breaktech.com>.
I answered my own question.
What I did was to explicitly send the OPTIONS & GET requests with the correct header information set rather than following redirects. This allowed the CORS header to be properly set on the file that was gotten so that other users were able to get it from cache without issue.

So here is what I did:

  *   I removed Follow Redirects from the original GET request
  *   Extracted the Location into 2 variables (URL and the rest of the location) from that original GET response header
  *   Added an OPTIONS request with the extracted URL and put the rest of the location in for the Path – do not Follow Redirects
  *   Added the following header values to he HTTP Header Manager under the OPTIONS request
     *   Access-Control-Request-Method: GET
     *   Access-Control-Request-Headers: origin
     *   Origin: https://<BaseURL>
  *   Added a GET with the same URL and Path as the OPTIONS request and same header values – do not Follow Redirects

I hope this will help someone else some day.
Beth


From: Beth Schrag <be...@breaktech.com>
Reply-To: JMeter Users List <us...@jmeter.apache.org>
Date: Wednesday, November 18, 2020 at 11:46 AM
To: JMeter Users List <us...@jmeter.apache.org>
Subject: CORS Redirect in JMeter

Hello,
I have a CORS-related question: Has anyone found a way to get JMeter to follow a redirect of a GET request by first sending an OPTIONS request with the appropriate CORS-related headers (Origin, Access-Control-Request-Headers, and Access-Control-Request-Method), followed by a GET request to the redirected URL?

It seems that JMeter doesn’t send the proper CORS-related headers on it’s own.

[cidimage001.jpg@01D698C9.3E168500]<http://www.breaktech.com/>
Beth Schrag
Software Engineer
C: 847.363.7306
Breakthrough Technologies LLC
General:847.864.0033
Visit us at breaktech.com<http://www.breaktech.com/>
[cidimage003.jpg@01D698C9.3E168500]<https://www.linkedin.com/company/breakthrough-technologies> [cidimage005.jpg@01D698C9.3E168500] <https://twitter.com/break_tech>  [cidimage007.jpg@01D698C9.3E168500] <https://www.facebook.com/Breakthrough-Technologies-282856188427598/>

Confidential information may be contained in this message. If you are not the addressee indicated in the message, you should destroy this message. @2020 Breakthrough Technologies, LLC.