Skip to content

Add support for servers with non-ASCII response headers #440

Closed

Description

Describe the bug

When I try to create a reverse proxy for the blog with the following response header:

access-control-allow-credentials: true
access-control-allow-origin: *
cache-control: public, max-age=0
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Fri, 25 Sep 2020 10:15:43 GMT
etag: W/"9127-u+4Jv+RfD2erbftmcMqr2DT5eig"
status: 304
strict-transport-security: max-age=315360000; includeSubDomains; preload
vary: Origin
x-powered-by: traefik(made with ❤️ with go)

It throws an expectation, InvalidOperationException: Invalid non-ASCII or control character in header: 0x00E2 in line 698 😂😂😂

var headerValue = new StringValues(header.Value.ToArray());
if (transforms.TryGetValue(headerName, out var transform))
{
(transformsRun ??= new HashSet<string>(StringComparer.OrdinalIgnoreCase)).Add(headerName);
headerValue = transform.Apply(context, response, headerValue);
}
if (!StringValues.IsNullOrEmpty(headerValue))
{
destination.Append(headerName, headerValue);
}

To Reproduce

  "ReverseProxy": {
    "Routes": [
      {
        "RouteId": "blog",
        "ClusterId": "blog",
        "Match": {
          "Path": "{**catch-all}"
        }
      }
    ],
    "Clusters": {
      "blog": {
        "Destinations": {
          "blog/destination1": {
            "Address": "https://yunfan.dev/"
          }
        }
      }
    }
  }

Further technical details

  • Microsoft.ReverseProxy: 1.0.0-preview.5.20467.3
  • Runtime
    .NET Core SDK (reflecting any global.json):
    Version:   3.1.402
    Commit:    9b5de826fd
    
    Runtime Environment:
    OS Name:     Windows
    OS Version:  10.0.19042
    OS Platform: Windows
    RID:         win10-x64
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions