// Copyright © WireMock.Net
using System.Net.Http;
using System.Net.Http.Headers;
namespace WireMock.Http;
internal static class ByteArrayContentHelper
{
///
/// Creates a ByteArrayContent object.
///
/// The byte[] content (cannot be null)
/// The ContentType (can be null)
/// ByteArrayContent
internal static ByteArrayContent Create(byte[] content, MediaTypeHeaderValue? contentType)
{
var byteContent = new ByteArrayContent(content);
if (contentType != null)
{
byteContent.Headers.Remove(HttpKnownHeaderNames.ContentType);
byteContent.Headers.ContentType = contentType;
}
return byteContent;
}
}