Skip to content

Commit

Permalink
Addressed styling issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ManickaP committed Feb 23, 2021
1 parent 0c977e2 commit a37e772
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
Expand All @@ -14,7 +15,6 @@
using Microsoft.Extensions.Hosting;
using Microsoft.ReverseProxy.Abstractions;
using Microsoft.ReverseProxy.Utilities.Tests;
using System.Text;

namespace Microsoft.ReverseProxy.Common
{
Expand Down
28 changes: 4 additions & 24 deletions test/ReverseProxy.FunctionalTests/HeaderEncodingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ public async Task ProxyAsync_RequestWithEncodedHeaderValue(string headerValue, s
return Task.CompletedTask;
}
});
proxyApp.UseMiddleware<CheckHeaderMiddleware>(HeaderNames.Referer, headerValue);
proxyApp.Use(async (context, next) =>
{
Assert.True(context.Request.Headers.TryGetValue(HeaderNames.Referer, out var header));
var value = Assert.Single(header);
Assert.Equal(headerValue, value);
await next();
proxyError = context.Features.Get<IProxyErrorFeature>();
});
Expand Down Expand Up @@ -201,29 +204,6 @@ public async Task ProxyAsync_ResponseWithEncodedHeaderValue(string headerValue,
}
}

private class CheckHeaderMiddleware
{
private readonly RequestDelegate _next;
private readonly string _headerName;
private readonly string _headerValue;

public CheckHeaderMiddleware(RequestDelegate next, string headerName, string headerValue)
{
_next = next;
_headerName = headerName;
_headerValue = headerValue;
}

public async Task Invoke(HttpContext context)
{
Assert.True(context.Request.Headers.TryGetValue(_headerName, out var header));
var value = Assert.Single(header);
Assert.Equal(_headerValue, value);

await _next.Invoke(context);
}
}

private class HeaderEncodingClientFactory : IProxyHttpClientFactory
{
private Encoding _encoding;
Expand Down

0 comments on commit a37e772

Please sign in to comment.