title: How to clear header manager programmatically
body: <p>I have a TestPlan </p>
  
  <pre><code>Thread-group
   HttpSampler
    pre-processor
    HttpHeaderManager[empty]
    HttpRequestDefaults[empty]
    Post-processor
  </code></pre>
  
  <p>I am using a pre-processor script to add headers dynamically to headerManager from reading a json file. it goes well .</p>
  
  <pre><code>import org.apache.jmeter.protocol.http.control.Header
  int min = args[0].toInteger()
  int max = args[1].toInteger()
  int random =  min + (int) (Math.random() * ((max - min) + 1));
  // here 'inputjson' referring to slurped json object
  
   inputjson.Headers.each{
          it.each{    key,value -&gt; sampler.getHeaderManager().add(new Header(key.replace('$random',random.toString()),value.replace('$random',(random+2).toString())));
                 }
      }
  </code></pre>
  
  <p>the issue is, if a thread loop count is 3, then the set of headers are adding 3 times.</p>
  
  <p>then I added a post processor script </p>
  
  <pre><code>sampler.getHeaderManager().clear()
  </code></pre>
  
  <p>This time initial[loop-1] run is going fine, next[loop-2] loop is a clear request with no headers. how can I achieve, each request will go with only 1 set of headers </p>