mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-23 16:58:27 +02:00
HttpContext
This commit is contained in:
@@ -23,7 +23,6 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
||||
private readonly IWireMockLogger _logger;
|
||||
private readonly HostUrlOptions _urlOptions;
|
||||
|
||||
private Exception _runningException;
|
||||
private IWebHost _host;
|
||||
|
||||
public bool IsStarted { get; private set; }
|
||||
@@ -32,7 +31,7 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
||||
|
||||
public List<int> Ports { get; } = new();
|
||||
|
||||
public Exception RunningException => _runningException;
|
||||
public Exception? RunningException { get; private set; }
|
||||
|
||||
public AspNetCoreSelfHost(IWireMockMiddlewareOptions wireMockMiddlewareOptions, HostUrlOptions urlOptions)
|
||||
{
|
||||
@@ -136,7 +135,7 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_runningException = e;
|
||||
RunningException = e;
|
||||
_logger.Error(e.ToString());
|
||||
|
||||
IsStarted = false;
|
||||
|
||||
@@ -9,12 +9,6 @@ using Microsoft.AspNetCore.Http.Extensions;
|
||||
using WireMock.Http;
|
||||
using WireMock.Models;
|
||||
using WireMock.Util;
|
||||
//#if !USE_ASPNETCORE
|
||||
//using IRequest = Microsoft.Owin.IOwinRequest;
|
||||
//#else
|
||||
//using Microsoft.AspNetCore.Http.Extensions;
|
||||
//using IRequest = Microsoft.AspNetCore.Http.HttpRequest;
|
||||
//#endif
|
||||
|
||||
namespace WireMock.Owin.Mappers;
|
||||
|
||||
@@ -76,10 +70,8 @@ internal class OwinRequestMapper : IOwinRequestMapper
|
||||
headers,
|
||||
cookies,
|
||||
httpVersion,
|
||||
//#if USE_ASPNETCORE
|
||||
await request.HttpContext.Connection.GetClientCertificateAsync()
|
||||
//#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
DateTime = DateTime.UtcNow
|
||||
};
|
||||
@@ -87,10 +79,6 @@ internal class OwinRequestMapper : IOwinRequestMapper
|
||||
|
||||
private static (UrlDetails UrlDetails, string ClientIP) ParseRequest(HttpRequest request)
|
||||
{
|
||||
//#if !USE_ASPNETCORE
|
||||
// var urlDetails = UrlUtils.Parse(request.Uri, request.PathBase);
|
||||
// var clientIP = request.RemoteIpAddress;
|
||||
//#else
|
||||
var urlDetails = UrlUtils.Parse(new Uri(request.GetEncodedUrl()), request.PathBase);
|
||||
|
||||
var connection = request.HttpContext.Connection;
|
||||
@@ -107,7 +95,7 @@ internal class OwinRequestMapper : IOwinRequestMapper
|
||||
{
|
||||
clientIP = connection.RemoteIpAddress.ToString();
|
||||
}
|
||||
//#endif
|
||||
|
||||
return (urlDetails, clientIP);
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,6 @@ using WireMock.ResponseBuilders;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
|
||||
//#if !USE_ASPNETCORE
|
||||
//using IResponse = Microsoft.Owin.IOwinResponse;
|
||||
//#else
|
||||
//using Microsoft.AspNetCore.Http;
|
||||
//using IResponse = Microsoft.AspNetCore.Http.HttpResponse;
|
||||
//#endif
|
||||
|
||||
namespace WireMock.Owin.Mappers
|
||||
{
|
||||
/// <summary>
|
||||
@@ -260,11 +253,7 @@ namespace WireMock.Owin.Mappers
|
||||
|
||||
private static void AppendResponseHeader(HttpResponse response, string headerName, string[] values)
|
||||
{
|
||||
//#if !USE_ASPNETCORE
|
||||
// response.Headers.AppendValues(headerName, values);
|
||||
//#else
|
||||
response.Headers.Append(headerName, values);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ internal class WireMockMiddleware
|
||||
await Task.Delay(_options.RequestProcessingDelay.Value).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var (theResponse, theOptionalNewMapping) = await targetMapping.ProvideResponseAsync(request).ConfigureAwait(false);
|
||||
var (theResponse, theOptionalNewMapping) = await targetMapping.ProvideResponseAsync(ctx, request).ConfigureAwait(false);
|
||||
response = theResponse;
|
||||
|
||||
var responseBuilder = targetMapping.Provider as Response;
|
||||
|
||||
Reference in New Issue
Block a user