/// <summary> /// Removes a specific request header from the header collection /// </summary> /// <param name="name"></param> public void RemoveContentHeader(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (ContentHeaders.ContainsKey(name)) { ContentHeaders.Remove(name); } }
public void SetContentHeader(string name, string value) { ContentHeaders ??= new(); if (ContentHeaders.ContainsKey(name)) { ContentHeaders[name] = value; } else { ContentHeaders.Add(name, value); } }
public override string ToString() { string contentEncoding = string.Empty; string debugString = string.Empty; if (ContentHeaders.ContainsKey(MIMEContentHeaders.ContentTransferEncoding) && InnerBody != null) { contentEncoding = ContentHeaders[MIMEContentHeaders.ContentTransferEncoding].Value; } byte[] readableBinaries = GetBytes(); switch (contentEncoding) { case MIMEContentTransferEncoding.Binary: int payLoadLength = 0; payLoadLength = InnerBody.Length; byte[] headers = new byte[readableBinaries.Length - payLoadLength]; Buffer.BlockCopy(readableBinaries, 0, headers, 0, headers.Length); if (InnerBody != null && InnerMessage == null) { if (ContentHeaders.ContainsKey(MIMEContentHeaders.BridgingOffsets)) { debugString = Encoding.UTF8.GetString(headers) + "\r\nMulti-Package Binary Data: {Length: " + payLoadLength + "}"; } else { debugString = Encoding.UTF8.GetString(headers) + "\r\nUnknown Binary Data: {Length: " + payLoadLength + "}"; } } if (InnerBody != null && InnerMessage != null) { debugString = Encoding.UTF8.GetString(headers) + "\r\n" + InnerMessage.ToString(); } break; default: debugString = Encoding.UTF8.GetString(readableBinaries); break; } return(debugString); }