HandleRequestsSynchronously (#496)

This commit is contained in:
Stef Heyenrath
2020-08-07 08:08:54 +02:00
committed by GitHub
parent c4ee91c614
commit b55435ddac
10 changed files with 54 additions and 15 deletions

View File

@@ -45,5 +45,7 @@ namespace WireMock.Owin
bool? DisableJsonBodyParsing { get; set; }
bool? DisableRequestBodyDecompressing { get; set; }
bool? HandleRequestsSynchronously { get; set; }
}
}

View File

@@ -25,6 +25,7 @@ namespace WireMock.Owin
{
internal class WireMockMiddleware : OwinMiddleware
{
private readonly object _lock = new object();
private static readonly Task CompletedTask = Task.FromResult(false);
private readonly IWireMockMiddlewareOptions _options;
private readonly IOwinRequestMapper _requestMapper;
@@ -65,7 +66,17 @@ namespace WireMock.Owin
public Task Invoke(IContext ctx)
#endif
{
return InvokeInternal(ctx);
if (_options.HandleRequestsSynchronously.GetValueOrDefault(true))
{
lock (_lock)
{
return InvokeInternal(ctx);
}
}
else
{
return InvokeInternal(ctx);
}
}
private async Task InvokeInternal(IContext ctx)

View File

@@ -51,5 +51,8 @@ namespace WireMock.Owin
/// <inheritdoc cref="IWireMockMiddlewareOptions.DisableRequestBodyDecompressing"/>
public bool? DisableRequestBodyDecompressing { get; set; }
/// <inheritdoc cref="IWireMockMiddlewareOptions.HandleRequestsSynchronously"/>
public bool? HandleRequestsSynchronously { get; set; }
}
}