title: How to prevent jmeter request from following a redirect
body: <p>There are two options under HTTP Request- <strong>Redirect Automatically</strong> and <strong>Follow Redirects</strong>. I want to implement behavior when <strong>Follow Redirects</strong> in unchecked</p>
  <pre><code>//CASE 1: HttpClient client = HttpClientBuilder.create().build();
  //CASE 2: HttpClient client = HttpClientBuilder.create().disableRedirectHandling().build();
  
  HttpGet get = new HttpGet(&quot;${request_link}&quot;);
  HttpResponse response = client.execute(get);
  SampleResult.setResponseData(EntityUtils.toByteArray(response.getEntity()));
  </code></pre>
  <p>I am using &quot;disableRedirectHandling&quot; as shown above in CASE 2 to stop auto re-direct. But I am getting a 200 response code instead of the expected 302.</p>
  <p>This is response I get for CASE 1:
  Response code: 200
  Response message: OK
  Response headers:</p>
  <p>But I am expecting below reponse:
  Response code: 302
  Response message: Found</p>
  <p>Response headers:
  HTTP/1.1 302 Found
  Date: Fri, 11 Jun 2021 00:32:45 GMT
  Content-Length: 0
  Connection: keep-alive
  Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  Pragma: no-cache
  Expires: 0
  Location: {redirect location link}</p>
  <p>Note:  disableRedirectHandling() is disabling <strong>Redirect Automatically</strong> but what I want to implement is <strong>Disable Follow Redirects</strong></p>
  <p>Basically I want something of this
  setRedirectsEnabled(false)
  OR setMaxRedirects(0)</p>
  <p>I tried this but no luck, Still getting re-direct</p>
  <pre><code>HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(RequestConfig.custom().setRedirectsEnabled(true).setMaxRedirects(0).build()).build();
  </code></pre>