CORS Redirect in JMeter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CORS Redirect in JMeter

Beth Schrag

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 (OriginAccess-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

Beth Schrag
Software Engineer
C: 847.363.7306

Breakthrough Technologies LLC
General:847.864.0033
Visit us at 
breaktech.com

cidimage003.jpg@01D698C9.3E168500 cidimage005.jpg@01D698C9.3E168500 cidimage007.jpg@01D698C9.3E168500

 

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.

 

Reply | Threaded
Open this post in threaded view
|

Re: CORS Redirect in JMeter

Beth Schrag

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 <[hidden email]>
Reply-To: JMeter Users List <[hidden email]>
Date: Wednesday, November 18, 2020 at 11:46 AM
To: JMeter Users List <[hidden email]>
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 (OriginAccess-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

Beth Schrag
Software Engineer
C: 847.363.7306

Breakthrough Technologies LLC
General:847.864.0033
Visit us at 
breaktech.com

cidimage003.jpg@01D698C9.3E168500 cidimage005.jpg@01D698C9.3E168500 cidimage007.jpg@01D698C9.3E168500

 

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.