WithProxy(...) also use all proxy settings (#550)

This commit is contained in:
Stef Heyenrath
2020-12-08 08:21:00 +01:00
committed by GitHub
parent 04d55b00a7
commit 35565f6aa8
17 changed files with 524 additions and 314 deletions

View File

@@ -7,7 +7,7 @@ using System.Net;
using System.Text;
using System.Threading.Tasks;
using JetBrains.Annotations;
using WireMock.Http;
using WireMock.Proxy;
using WireMock.ResponseProviders;
using WireMock.Settings;
using WireMock.Transformers;
@@ -312,7 +312,7 @@ namespace WireMock.ResponseBuilders
await Task.Delay(Delay.Value);
}
if (ProxyUrl != null && _httpClientForProxy != null)
if (ProxyAndRecordSettings != null && _httpClientForProxy != null)
{
string RemoveFirstOccurrence(string source, string find)
{
@@ -323,16 +323,19 @@ namespace WireMock.ResponseBuilders
var requestUri = new Uri(requestMessage.Url);
// Build the proxy url and skip duplicates
string extra = RemoveFirstOccurrence(requestUri.LocalPath.TrimEnd('/'), new Uri(ProxyUrl).LocalPath.TrimEnd('/'));
requestMessage.ProxyUrl = ProxyUrl + extra + requestUri.Query;
string extra = RemoveFirstOccurrence(requestUri.LocalPath.TrimEnd('/'), new Uri(ProxyAndRecordSettings.Url).LocalPath.TrimEnd('/'));
requestMessage.ProxyUrl = ProxyAndRecordSettings.Url + extra + requestUri.Query;
return await HttpClientHelper.SendAsync(
var proxyHelper = new ProxyHelper(settings);
var (proxyResponseMessage, mapping) = await proxyHelper.SendAsync(
ProxyAndRecordSettings,
_httpClientForProxy,
requestMessage,
requestMessage.ProxyUrl,
!settings.DisableJsonBodyParsing.GetValueOrDefault(false),
!settings.DisableRequestBodyDecompressing.GetValueOrDefault(false)
requestMessage.ProxyUrl
);
return proxyResponseMessage;
}
ResponseMessage responseMessage;