ProxyFeature - Add Headers

Hi demis,
my use case: proxy an api & append some header fields.

docs (

// Customize the HTTP Request Headers that are sent to downstream server
Action<IHttpRequest, HttpWebRequest> ProxyRequestFilter

How are we supposed to e.g. add a header value?

As soon is i add this line, the proxy wont work anymore:
ProxyRequestFilter = (request, webRequest) => webRequest.Headers.Add("Some-Header", "xxx"),

the ss-api interestingly returns with a 200, but the request never hits my downstream server + there is no response.

request.Headers.Add() throws not implemented exception. my downstream is a simple to test.

Full code:

Plugins.Add(new ProxyFeature(
            matchingRequests: req => req.PathInfo.StartsWith("/proxy-api"),
            resolveUrl: req => $"" + req.RawUrl.Replace("/proxy-api", ""))
            ProxyRequestFilter = (request, webRequest) => webRequest.Headers.Add("XXX", "YYY"),

That’s how the ProxyFeature is adding the forwarding Request Headers:

So it should also work for your user-defined headers, try using a HTTP Inspector like WIreShark or Fiddler to see what the downstream request is.

request is the incoming IHttpRequest which is immutable, the outgoing proxied HttpWebRequest is the second parameter which should be used to customize the proxy request.