Родитель
a0e449f42e
Коммит
af6d56c5f8
|
@ -1644,6 +1644,33 @@ namespace Yarp.ReverseProxy.Service.Proxy.Tests
|
|||
destinationPrefix, httpClient, requestOptions, transforms));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("HTTP/1.1", "1.1")]
|
||||
[InlineData("HTTP/2", "2.0")]
|
||||
public async Task ProxyAsync_Expect100ContinueWithFailedResponse_ReturnResponse(string fromProtocol, string toProtocol)
|
||||
{
|
||||
var httpContext = new DefaultHttpContext();
|
||||
httpContext.Request.Method = "GET";
|
||||
httpContext.Request.Protocol = fromProtocol;
|
||||
httpContext.Request.Headers[HeaderNames.Expect] = "100-continue";
|
||||
using var contentStream = new MemoryStream(Encoding.UTF8.GetBytes(new string('a', 1024 * 1024 * 10)));
|
||||
httpContext.Request.Body = contentStream;
|
||||
|
||||
var destinationPrefix = "https://localhost:123/a/b/";
|
||||
var sut = CreateProxy();
|
||||
var client = MockHttpHandler.CreateClient(
|
||||
async (HttpRequestMessage request, CancellationToken cancellationToken) =>
|
||||
{
|
||||
await Task.Yield();
|
||||
return new HttpResponseMessage(HttpStatusCode.Conflict);
|
||||
});
|
||||
|
||||
await sut.ProxyAsync(httpContext, destinationPrefix, client, new RequestProxyConfig { Version = Version.Parse(toProtocol) });
|
||||
|
||||
Assert.Equal(0, contentStream.Position);
|
||||
Assert.Equal((int)HttpStatusCode.Conflict, httpContext.Response.StatusCode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1.1", false, "Connection: upgrade; Upgrade: test123", null, "Connection; Upgrade")]
|
||||
[InlineData("1.1", false, "Connection: keep-alive; Keep-Alive: timeout=100", null, "Connection; Keep-Alive")]
|
||||
|
|
|
@ -11,10 +11,10 @@ using System.Threading.Tasks;
|
|||
namespace SampleClient.Scenarios
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies that Island Gateway correctly handles the case where the client specifies
|
||||
/// Verifies that YARP correctly handles the case where the client specifies
|
||||
/// <c>Expect: 100-continue</c> and the destination fails early without accepting the request body.
|
||||
/// This scenario can be encountered in real world scenarios, usually when authentication fails on the destination.
|
||||
/// The <c>Expect: 100-continue</c> behavior causes the request body copy to not even start on Island Gateway in this case.
|
||||
/// The <c>Expect: 100-continue</c> behavior causes the request body copy to not even start on YARP in this case.
|
||||
/// </summary>
|
||||
internal class Http2PostExpectContinueScenario : IScenario
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче