// Copyright (C) 2020 White Sharx (https://whitesharx.com) - All Rights Reserved. // Unauthorized copying of this file, via any medium is strictly prohibited. // Proprietary and confidential. // using System.Collections.Generic; using System.Linq; using Httx.Requests.Extensions; namespace Httx.Requests.Types { public class Json : BaseRequest { public Json(string url, TBody body = default) : base(null) { Url = url; if (typeof(TBody) == typeof(byte[])) { Body = (byte[])(object)body; } else { Body = Equals(body, default(TBody)) ? default : this.ResolveBodyMapper(Context.Instance).AsBody(body); } } public override string Url { get; } public override IEnumerable Body { get; } public override IEnumerable> Headers { get { var headers = new Dictionary { { "Accept", "application/json;charset=UTF-8" } }; if (null != Body && 0 != Body.Count()) { headers.Add("Content-Type", "application/json;charset=UTF-8"); } return headers; } } } public class Json : Json { public Json(string url, byte[] body = default) : base(url, body) { } } }