title: Jersey WebResource Dynamic Headers
body: <p>I want to be able to set header dynamically. This line works for me:</p>
  
  <pre><code>WebResource webResource = client.resource(doSomethingURL);
  webResource
                  .header("test1", test1)
                  .post(ClientResponse.class, postData);
  </code></pre>
  
  <p>But it makes code unnecessary long while writing dynamic headers. I want to do something like:</p>
  
  <pre><code>WebResource webResource = client.resource(doSomethingURL);
  
  if(a&gt;b){
          webResource.header("test1",test1);
      }else{
          webResource.header("test2",test2);
      }
  
  webResource.post(ClientResponse.class, postData);
  </code></pre>
  
  <p>I tried this but it throws error for some reason:</p>
  
  <pre><code>ClientResponse response = getWebResource(URI + "something").post(ClientResponse.class, DataForPost);
  
  public WebResource getWebResource(String url){
          WebResource webResource = client.resource(url);
          webResource
                  .header("test1", test1);
  
          return webResource;
      }
  </code></pre>
  
  <p>Error I get is:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.lang.Class cannot be cast to com.sun.jersey.api.client.ClientResponse</p>
  </blockquote>