mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 10:18:26 +02:00
WithBodyFromFile (#56)
This commit is contained in:
@@ -39,7 +39,7 @@ namespace WireMock.Owin
|
||||
}
|
||||
responseMessage.Headers.Where(h => h.Key != HttpKnownHeaderNames.ContentType).ToList().ForEach(pair => response.Headers.Append(pair.Key, pair.Value));
|
||||
|
||||
if (responseMessage.Body == null && responseMessage.BodyAsBytes == null)
|
||||
if (responseMessage.Body == null && responseMessage.BodyAsBytes == null && responseMessage.BodyAsFile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -49,6 +49,14 @@ namespace WireMock.Owin
|
||||
await response.Body.WriteAsync(responseMessage.BodyAsBytes, 0, responseMessage.BodyAsBytes.Length);
|
||||
return;
|
||||
}
|
||||
|
||||
if (responseMessage.BodyAsFile != null)
|
||||
{
|
||||
byte[] bytes = File.ReadAllBytes(responseMessage.BodyAsFile);
|
||||
|
||||
await response.Body.WriteAsync(bytes, 0, bytes.Length);
|
||||
return;
|
||||
}
|
||||
|
||||
Encoding encoding = responseMessage.BodyEncoding ?? _utf8NoBom;
|
||||
using (var writer = new StreamWriter(response.Body, encoding))
|
||||
|
||||
Reference in New Issue
Block a user