title: Modify request header in zuul filter
body: <p>I have a backend service which accepts Authorization header to validate access. I created a Gateway service with Spring cloud zuul and routed requests to backend service.</p>
  
  <p>Gateway service itself is protected with OAuth2 and accepts a Authorization header to validate access. Now once the request authorizes to gateway service, Gateway service act as a client to send an updated Access token in the header by using it's clientid,secret and backend service resource ID. As it has to send Authorization header, I was trying to update the Authorization header in the request but it is taking for below two ways.</p>
  
  <pre><code>ctx = RequestContext.getCurrentContext();
  ctx.addZuulRequestHeader("Authorization", accessToken);
  </code></pre>
  
  <p>With the above code it is adding Authorization header but it is adding it to zuul headers which the backend service is not identiyfying.</p>
  
  <p>I have created a wrapper to modify the request object but it is not working</p>
  
  <pre><code>public class RequestWrapper extends HttpServletRequestWrapper
  {
      private final Map&lt;String, String[]&gt; modifiableParameters;
      private Map&lt;String, String[]&gt; allParameters = null;
  
      public RequestWrapper(final HttpServletRequest request, 
                                                      final Map&lt;String, String[]&gt; additionalParams)
      {
          super(request);
          modifiableParameters = new TreeMap&lt;String, String[]&gt;();
          modifiableParameters.putAll(additionalParams);
      }
  
      @Override
      public String getParameter(final String name)
      {
          String[] strings = getParameterMap().get(name);
          if (strings != null)
          {
              return strings[0];
          }
          return super.getParameter(name);
      }
  
      @Override
      public Map&lt;String, String[]&gt; getParameterMap()
      {
          if (allParameters == null)
          {
              allParameters = new TreeMap&lt;String, String[]&gt;();
              allParameters.putAll(super.getParameterMap());
              allParameters.putAll(modifiableParameters);
          }
  
          return Collections.unmodifiableMap(allParameters);
      }
  
      @Override
      public Enumeration&lt;String&gt; getParameterNames()
      {
          return Collections.enumeration(getParameterMap().keySet());
      }
  
      @Override
      public String[] getParameterValues(final String name)
      {
          return getParameterMap().get(name);
      }
  }
  </code></pre>
  
  <p>Above wrapper is found from <a href="http://www.ocpsoft.org/opensource/how-to-safely-add-modify-servlet-request-parameter-values/" rel="nofollow noreferrer">http://www.ocpsoft.org/opensource/how-to-safely-add-modify-servlet-request-parameter-values/</a>
  and called it in the zuul filter        </p>
  
  <pre><code>    authToken = getAuthToken();     
      String accessToken = "Bearer " + authToken;
      Map&lt;String,String[]&gt; additionalParams = new HashMap&lt;&gt;();
  
      additionalParams.put("Authorization", new String[] {accessToken});     
     ctx.setRequest(new RequestWrapper(request, additionalParams));
  </code></pre>
  
  <p>What am I doing wrong or any other way of modifying request header?</p>