title: Jersey 2 filter uses Container Request Context in Client Request Filter
body: <p>I have a Jersey 2 Web Service that upon receiving a request, makes another request to another web service in order to form the response for the original request. So, when client "A" makes a request to my web service "B", "B" makes a request to "C" as part of forming the response to "A".</p>
  
  <p>A->B->C</p>
  
  <p>I want to implement a filter for a Jersey 2 web service that essentially does this:</p>
  
  <ul>
  <li><p>Client "A" will send a request that has a header like
  "My-Header:first"</p></li>
  <li><p>When my web service "B" then makes a client request "C", it should
  append to that header, so it sends a request with this header
  "My-Header:first,second".</p></li>
  </ul>
  
  <p>I want to implement this as a filter so all of my resources don't have to duplicate the logic of appending to the request header.</p>
  
  <p>However, in Jersey 2, you get these 4 filters:</p>
  
  <ul>
  <li>ContainerRequestFilter - Filter/modify inbound requests</li>
  <li>ContainerResponseFilter - Filter/modify outbound responses</li>
  <li>ClientRequestFilter - Filter/modify outbound requests</li>
  <li>ClientResponseFilter - Filter/modify inbound responses</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/wbSLK.png" alt="Jersey Filter Diagram"></p>
  
  <p>I need to use the header from an inbound request, modify it, then use it an outbound request, so essentially I need something that is both a ContainerRequestFilter and a ClientRequestFilter. I don't think implementing both in the same filter will work, as you don't know which Client Request maps to which Container Request, or do you?</p>