32 lines
848 B
C#
32 lines
848 B
C#
using System;
|
|
namespace ln.http
|
|
{
|
|
public class HttpHeader
|
|
{
|
|
public String Name { get; }
|
|
public String Value { get; }
|
|
|
|
public HttpHeader(String rawHeader)
|
|
{
|
|
int colon = rawHeader.IndexOf(':');
|
|
if (colon < 0)
|
|
throw new FormatException("rawHeader must contain at least one colon");
|
|
|
|
Name = rawHeader.Substring(0, colon).Trim().ToUpper();
|
|
Value = rawHeader.Substring(colon + 1).Trim();
|
|
}
|
|
|
|
public HttpHeader(String headerName,String headerValue)
|
|
{
|
|
if (String.Empty.Equals(headerName))
|
|
throw new ArgumentException("headerName needs to contain at least one character", nameof(headerName));
|
|
|
|
Name = headerName.ToUpper();
|
|
Value = headerValue.ToUpper();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|