mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 18:11:10 +01:00
Fix issues with Proxy mode and Binary Request Bodies (#334)
* Add Test for Proxy with binary request * Fix binary parsing in BodyParser * Fix binary Matching in RequestMessageBodyMatcher * Improved Binary Matching in RequestMessageBodyMatcher * BodyParser: Add test for Content Autodetection * RequestMessageBodyMatcherTests: Make Code more pretty :) * BodyParserChanges: Revert white space changes * Fixed test for different behavior in request matching
This commit is contained in:
@@ -145,17 +145,17 @@ namespace WireMock.Matchers.Request
|
||||
|
||||
if (Func != null)
|
||||
{
|
||||
return MatchScores.ToScore(requestMessage?.BodyData?.DetectedBodyType == BodyType.String && Func(requestMessage.BodyData.BodyAsString));
|
||||
return MatchScores.ToScore(Func(requestMessage?.BodyData?.BodyAsString));
|
||||
}
|
||||
|
||||
if (JsonFunc != null)
|
||||
{
|
||||
return MatchScores.ToScore(requestMessage?.BodyData?.DetectedBodyType == BodyType.Json && JsonFunc(requestMessage.BodyData.BodyAsJson));
|
||||
return MatchScores.ToScore(JsonFunc(requestMessage?.BodyData?.BodyAsJson));
|
||||
}
|
||||
|
||||
if (DataFunc != null)
|
||||
{
|
||||
return MatchScores.ToScore(requestMessage?.BodyData?.DetectedBodyType == BodyType.Bytes && DataFunc(requestMessage.BodyData.BodyAsBytes));
|
||||
return MatchScores.ToScore(DataFunc(requestMessage?.BodyData?.BodyAsBytes));
|
||||
}
|
||||
|
||||
return MatchScores.Mismatch;
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace WireMock.Util
|
||||
{
|
||||
internal static class BodyParser
|
||||
{
|
||||
private static readonly Encoding DefaultEncoding = Encoding.UTF8;
|
||||
private static readonly Encoding[] SupportedBodyAsStringEncodingForMultipart = { Encoding.UTF8, Encoding.ASCII };
|
||||
private static readonly Encoding DefaultEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
|
||||
private static readonly Encoding[] SupportedBodyAsStringEncodingForMultipart = { DefaultEncoding, Encoding.ASCII };
|
||||
|
||||
/*
|
||||
HEAD - No defined body semantics.
|
||||
|
||||
Reference in New Issue
Block a user