You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Apewer.Network
|
|
{
|
|
|
|
/// <summary>HTTP 头。</summary>
|
|
[Serializable]
|
|
public sealed class HttpHeader
|
|
{
|
|
|
|
string _name = null;
|
|
string _value = null;
|
|
|
|
/// <summary>名称。</summary>
|
|
public string Name { get => _name; set => _name = value?.Trim(); }
|
|
|
|
/// <summary>值。</summary>
|
|
public string Value { get => _value; set => _value = value?.Trim(); }
|
|
|
|
/// <summary>创建 HTTP 头的实例。</summary>
|
|
public HttpHeader() { }
|
|
|
|
/// <summary>创建 HTTP 头的实例。</summary>
|
|
/// <exception cref="ArgumentException" />
|
|
public HttpHeader(KeyValuePair<string, string> keyValuePair)
|
|
{
|
|
if (keyValuePair.Key.IsEmpty()) throw new ArgumentNullException("Key 无效。");
|
|
|
|
Name = keyValuePair.Key;
|
|
Value = keyValuePair.Value;
|
|
}
|
|
|
|
/// <summary>创建 HTTP 头的实例。</summary>
|
|
/// <exception cref="ArgumentNullException" />
|
|
public HttpHeader(string name, string value)
|
|
{
|
|
if (name.IsEmpty()) throw new ArgumentNullException(nameof(name));
|
|
|
|
Name = name;
|
|
Value = value;
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public override string ToString() => $"{Name}: {Value}";
|
|
|
|
}
|
|
|
|
}
|
|
|