internal void ThrowOnRestrictedHeader(string headerName)
{
if (_type == WebHeaderCollectionType.HttpWebRequest)
{
if (HeaderInfo[headerName].IsRequestRestricted)
{
throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
}
}
else if (_type == WebHeaderCollectionType.HttpListenerResponse)
{
if (HeaderInfo[headerName].IsResponseRestricted)
{
throw new ArgumentException(string.Format(SR.net_headerrestrict, headerName), nameof(headerName));
}
}
}