mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 16:58:27 +02:00
HandleRequestsSynchronously (#496)
This commit is contained in:
@@ -45,5 +45,7 @@ namespace WireMock.Owin
|
||||
bool? DisableJsonBodyParsing { get; set; }
|
||||
|
||||
bool? DisableRequestBodyDecompressing { get; set; }
|
||||
|
||||
bool? HandleRequestsSynchronously { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user