diff --git a/Directory.Build.props b/Directory.Build.props
index a0b6b3ea..8031a4fb 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
- 1.0.11
+ 1.0.12
diff --git a/examples/WireMock.Net.Console.Proxy.Net452/Program.cs b/examples/WireMock.Net.Console.Proxy.Net452/Program.cs
index 5a0c5d52..d635c91a 100644
--- a/examples/WireMock.Net.Console.Proxy.Net452/Program.cs
+++ b/examples/WireMock.Net.Console.Proxy.Net452/Program.cs
@@ -1,4 +1,6 @@
-using Newtonsoft.Json;
+using System;
+using System.Net.Http;
+using Newtonsoft.Json;
using WireMock.Server;
using WireMock.Settings;
@@ -8,14 +10,15 @@ namespace WireMock.Net.Console.Proxy.Net452
{
static void Main(string[] args)
{
+ string[] urls = { "http://localhost:9091/", "https://localhost:9443/" };
var server = FluentMockServer.Start(new FluentMockServerSettings
{
- Urls = new[] { "http://localhost:9091/", "https://localhost:9443/" },
+ Urls = urls,
StartAdminInterface = true,
ReadStaticMappings = false,
ProxyAndRecordSettings = new ProxyAndRecordSettings
{
- Url = "https://www.google.com",
+ Url = "http://postman-echo.com/post",
//ClientX509Certificate2ThumbprintOrSubjectName = "www.yourclientcertname.com OR yourcertificatethumbprint (only if the service you're proxying to requires it)",
SaveMapping = true,
SaveMappingToFile = false,
@@ -28,6 +31,13 @@ namespace WireMock.Net.Console.Proxy.Net452
System.Console.WriteLine(JsonConvert.SerializeObject(eventRecordArgs.NewItems, Formatting.Indented));
};
+ var uri = new Uri(urls[0]);
+ var form = new MultipartFormDataContent
+ {
+ { new StringContent("data"), "test", "test.txt" }
+ };
+ new HttpClient().PostAsync(uri, form).GetAwaiter().GetResult();
+
System.Console.WriteLine("Press any key to stop the server");
System.Console.ReadKey();
server.Stop();
diff --git a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs
index 4f8847c7..bfe87509 100644
--- a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs
+++ b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs
@@ -1,5 +1,5 @@
-using System.Linq;
-using JetBrains.Annotations;
+using JetBrains.Annotations;
+using System.Linq;
using WireMock.Validation;
namespace WireMock.Matchers
@@ -10,8 +10,9 @@ namespace WireMock.Matchers
///
public class ExactObjectMatcher : IObjectMatcher
{
- private readonly object _object;
- private readonly byte[] _bytes;
+ public object ValueAsObject { get; }
+
+ public byte[] ValueAsBytes { get; }
///
public MatchBehaviour MatchBehaviour { get; }
@@ -33,7 +34,7 @@ namespace WireMock.Matchers
{
Check.NotNull(value, nameof(value));
- _object = value;
+ ValueAsObject = value;
MatchBehaviour = matchBehaviour;
}
@@ -54,14 +55,14 @@ namespace WireMock.Matchers
{
Check.NotNull(value, nameof(value));
- _bytes = value;
+ ValueAsBytes = value;
MatchBehaviour = matchBehaviour;
}
///
public double IsMatch(object input)
{
- bool equals = _object != null ? Equals(_object, input) : _bytes.SequenceEqual((byte[])input);
+ bool equals = ValueAsObject != null ? Equals(ValueAsObject, input) : ValueAsBytes.SequenceEqual((byte[])input);
return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(equals));
}
diff --git a/src/WireMock.Net/ResponseMessageBuilder.cs b/src/WireMock.Net/ResponseMessageBuilder.cs
index b4903e89..7a14ffd9 100644
--- a/src/WireMock.Net/ResponseMessageBuilder.cs
+++ b/src/WireMock.Net/ResponseMessageBuilder.cs
@@ -9,7 +9,10 @@ namespace WireMock
internal static class ResponseMessageBuilder
{
private static string ContentTypeJson = "application/json";
- private static readonly IDictionary> ContentTypeJsonHeaders = new Dictionary> { { HttpKnownHeaderNames.ContentType, new WireMockList { ContentTypeJson } } };
+ private static readonly IDictionary> ContentTypeJsonHeaders = new Dictionary>
+ {
+ { HttpKnownHeaderNames.ContentType, new WireMockList { ContentTypeJson } }
+ };
internal static ResponseMessage Create(string message, int statusCode = 200, Guid? guid = null)
{
diff --git a/src/WireMock.Net/Serialization/MatcherMapper.cs b/src/WireMock.Net/Serialization/MatcherMapper.cs
index 53aabf27..57b128e5 100644
--- a/src/WireMock.Net/Serialization/MatcherMapper.cs
+++ b/src/WireMock.Net/Serialization/MatcherMapper.cs
@@ -1,8 +1,8 @@
-using System;
+using JetBrains.Annotations;
+using SimMetrics.Net;
+using System;
using System.Collections.Generic;
using System.Linq;
-using JetBrains.Annotations;
-using SimMetrics.Net;
using WireMock.Admin.Mappings;
using WireMock.Matchers;
@@ -32,6 +32,10 @@ namespace WireMock.Serialization
case "ExactMatcher":
return new ExactMatcher(matchBehaviour, stringPatterns);
+ case "ExactObjectMatcher":
+ var bytePattern = Convert.FromBase64String(stringPatterns[0]);
+ return new ExactObjectMatcher(matchBehaviour, bytePattern);
+
case "RegexMatcher":
return new RegexMatcher(matchBehaviour, stringPatterns, matcher.IgnoreCase == true);
@@ -73,20 +77,33 @@ namespace WireMock.Serialization
return null;
}
- // If the matcher is a IStringMatcher, get the patterns.
- // If the matcher is a IValueMatcher, get the value (can be string or object).
- // Else empty array
- object[] patterns = matcher is IStringMatcher stringMatcher ?
- stringMatcher.GetPatterns().Cast