mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 14:43:40 +02:00
HttpClientHelper : BodyAsBytes
This commit is contained in:
@@ -30,6 +30,13 @@ namespace WireMock.Net.ConsoleApplication
|
|||||||
|
|
||||||
// server.AllowPartialMapping();
|
// server.AllowPartialMapping();
|
||||||
|
|
||||||
|
server
|
||||||
|
.Given(Request.Create().WithHeader("ProxyThis", "true")
|
||||||
|
.UsingGet())
|
||||||
|
.RespondWith(Response.Create()
|
||||||
|
.WithProxy("http://www.google.com")
|
||||||
|
);
|
||||||
|
|
||||||
server
|
server
|
||||||
.Given(Request.Create().WithPath("/bodyasbytes.png")
|
.Given(Request.Create().WithPath("/bodyasbytes.png")
|
||||||
.UsingGet())
|
.UsingGet())
|
||||||
|
|||||||
@@ -2,15 +2,12 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Security.Authentication;
|
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WireMock.Http
|
namespace WireMock.Http
|
||||||
{
|
{
|
||||||
internal static class HttpClientHelper
|
internal static class HttpClientHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
private static HttpClient CreateHttpClient(string clientX509Certificate2ThumbprintOrSubjectName = null)
|
private static HttpClient CreateHttpClient(string clientX509Certificate2ThumbprintOrSubjectName = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(clientX509Certificate2ThumbprintOrSubjectName))
|
if (!string.IsNullOrEmpty(clientX509Certificate2ThumbprintOrSubjectName))
|
||||||
@@ -25,8 +22,6 @@ namespace WireMock.Http
|
|||||||
|
|
||||||
var x509Certificate2 = CertificateUtil.GetCertificate(clientX509Certificate2ThumbprintOrSubjectName);
|
var x509Certificate2 = CertificateUtil.GetCertificate(clientX509Certificate2ThumbprintOrSubjectName);
|
||||||
handler.ClientCertificates.Add(x509Certificate2);
|
handler.ClientCertificates.Add(x509Certificate2);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
var handler = new WebRequestHandler
|
var handler = new WebRequestHandler
|
||||||
{
|
{
|
||||||
@@ -76,7 +71,7 @@ namespace WireMock.Http
|
|||||||
{
|
{
|
||||||
StatusCode = (int)httpResponseMessage.StatusCode,
|
StatusCode = (int)httpResponseMessage.StatusCode,
|
||||||
|
|
||||||
// TODO : what about BodyAsBytes ???
|
BodyAsBytes = await httpResponseMessage.Content.ReadAsByteArrayAsync(),
|
||||||
Body = await httpResponseMessage.Content.ReadAsStringAsync()
|
Body = await httpResponseMessage.Content.ReadAsStringAsync()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user