15 [global::__DynamicallyInvokable]
18 internal static class HeaderEncoding
20 internal unsafe
static string GetString(
byte[] bytes,
int byteIndex,
int byteCount)
22 fixed (
byte* ptr = bytes)
24 return GetString(ptr + byteIndex, byteCount);
28 internal unsafe
static string GetString(
byte* pBytes,
int byteCount)
34 string text =
new string(
'\0', byteCount);
35 fixed (
char* ptr = text)
38 while (byteCount >= 8)
40 *ptr2 = (char)(*pBytes);
41 ptr2[1] = (char)pBytes[1];
42 ptr2[2] = (char)pBytes[2];
43 ptr2[3] = (char)pBytes[3];
44 ptr2[4] = (char)pBytes[4];
45 ptr2[5] = (char)pBytes[5];
46 ptr2[6] = (char)pBytes[6];
47 ptr2[7] = (char)pBytes[7];
52 for (
int i = 0; i < byteCount; i++)
54 ptr2[i] = (char)pBytes[i];
60 internal static int GetByteCount(
string myString)
62 return myString.Length;
65 internal unsafe
static void GetBytes(
string myString,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
67 if (myString.Length != 0)
69 fixed (
byte* ptr = bytes)
71 byte* ptr2 = ptr + byteIndex;
72 int num = charIndex + charCount;
73 while (charIndex < num)
77 *intPtr = (byte)myString[charIndex++];
83 internal static byte[] GetBytes(
string myString)
85 byte[] array =
new byte[myString.Length];
86 if (myString.Length != 0)
88 GetBytes(myString, 0, myString.Length, array, 0);
94 internal static string DecodeUtf8FromString(
string input)
96 if (
string.IsNullOrWhiteSpace(input))
101 for (
int i = 0; i < input.Length; i++)
107 if (input[i] >
'\u007f')
115 byte[] array =
new byte[input.Length];
116 for (
int j = 0; j < input.Length; j++)
122 array[j] = (byte)input[j];
138 private enum RfcChar :
byte 150 private const int ApproxAveHeaderLineSize = 30;
152 private const int ApproxHighAvgNumHeaders = 16;
154 private static readonly HeaderInfoTable HInfo =
new HeaderInfoTable();
156 private string[] m_CommonHeaders;
158 private int m_NumCommonHeaders;
160 private static readonly
string[] s_CommonHeaderNames =
new string[19]
171 "Proxy-Authenticate",
183 private static readonly sbyte[] s_CommonHeaderHints =
new sbyte[32]
219 private const int c_AcceptRanges = 0;
221 private const int c_ContentLength = 1;
223 private const int c_CacheControl = 2;
225 private const int c_ContentType = 3;
227 private const int c_Date = 4;
229 private const int c_Expires = 5;
231 private const int c_ETag = 6;
233 private const int c_LastModified = 7;
235 private const int c_Location = 8;
237 private const int c_ProxyAuthenticate = 9;
239 private const int c_P3P = 10;
241 private const int c_SetCookie2 = 11;
243 private const int c_SetCookie = 12;
245 private const int c_Server = 13;
247 private const int c_Via = 14;
249 private const int c_WwwAuthenticate = 15;
251 private const int c_XAspNetVersion = 16;
253 private const int c_XPoweredBy = 17;
257 private WebHeaderCollectionType m_Type;
259 private static readonly
char[] HttpTrimCharacters =
new char[6]
269 private static RfcChar[] RfcCharMap =
new RfcChar[128]
401 internal string ContentLength
405 if (m_CommonHeaders ==
null)
407 return Get(s_CommonHeaderNames[1]);
409 return m_CommonHeaders[1];
413 internal string CacheControl
417 if (m_CommonHeaders ==
null)
419 return Get(s_CommonHeaderNames[2]);
421 return m_CommonHeaders[2];
425 internal string ContentType
429 if (m_CommonHeaders ==
null)
431 return Get(s_CommonHeaderNames[3]);
433 return m_CommonHeaders[3];
441 if (m_CommonHeaders ==
null)
443 return Get(s_CommonHeaderNames[4]);
445 return m_CommonHeaders[4];
449 internal string Expires
453 if (m_CommonHeaders ==
null)
455 return Get(s_CommonHeaderNames[5]);
457 return m_CommonHeaders[5];
465 if (m_CommonHeaders ==
null)
467 return Get(s_CommonHeaderNames[6]);
469 return m_CommonHeaders[6];
473 internal string LastModified
477 if (m_CommonHeaders ==
null)
479 return Get(s_CommonHeaderNames[7]);
481 return m_CommonHeaders[7];
485 internal string Location
489 string input = (m_CommonHeaders !=
null) ? m_CommonHeaders[8] :
Get(s_CommonHeaderNames[8]);
490 return HeaderEncoding.DecodeUtf8FromString(input);
494 internal string ProxyAuthenticate
498 if (m_CommonHeaders ==
null)
500 return Get(s_CommonHeaderNames[9]);
502 return m_CommonHeaders[9];
506 internal string SetCookie2
510 if (m_CommonHeaders ==
null)
512 return Get(s_CommonHeaderNames[11]);
514 return m_CommonHeaders[11];
518 internal string SetCookie
522 if (m_CommonHeaders ==
null)
524 return Get(s_CommonHeaderNames[12]);
526 return m_CommonHeaders[12];
530 internal string Server
534 if (m_CommonHeaders ==
null)
536 return Get(s_CommonHeaderNames[13]);
538 return m_CommonHeaders[13];
546 if (m_CommonHeaders ==
null)
548 return Get(s_CommonHeaderNames[14]);
550 return m_CommonHeaders[14];
558 if (m_InnerCollection ==
null)
562 return m_InnerCollection;
566 private bool AllowHttpRequestHeader
570 if (m_Type == WebHeaderCollectionType.Unknown)
572 m_Type = WebHeaderCollectionType.WebRequest;
574 if (m_Type != WebHeaderCollectionType.WebRequest && m_Type != WebHeaderCollectionType.HttpWebRequest)
576 return m_Type == WebHeaderCollectionType.HttpListenerRequest;
582 internal bool AllowHttpResponseHeader
586 if (m_Type == WebHeaderCollectionType.Unknown)
588 m_Type = WebHeaderCollectionType.WebResponse;
590 if (m_Type != WebHeaderCollectionType.WebResponse && m_Type != WebHeaderCollectionType.HttpWebResponse)
592 return m_Type == WebHeaderCollectionType.HttpListenerResponse;
602 [global::__DynamicallyInvokable]
605 [global::__DynamicallyInvokable]
608 if (!AllowHttpRequestHeader)
612 return base[UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((
int)header)];
614 [global::__DynamicallyInvokable]
617 if (!AllowHttpRequestHeader)
621 base[UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((
int)header)] = value;
630 [global::__DynamicallyInvokable]
633 [global::__DynamicallyInvokable]
636 if (!AllowHttpResponseHeader)
640 if (m_CommonHeaders !=
null)
645 return m_CommonHeaders[9];
647 return m_CommonHeaders[15];
650 return base[UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header)];
652 [global::__DynamicallyInvokable]
655 if (!AllowHttpResponseHeader)
659 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
663 base[UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header)] = value;
669 [global::__DynamicallyInvokable]
670 public override int Count 672 [global::__DynamicallyInvokable]
675 return ((m_InnerCollection !=
null) ? m_InnerCollection.
Count : 0) + m_NumCommonHeaders;
681 public override KeysCollection
Keys 685 NormalizeCommonHeaders();
686 return InnerCollection.
Keys;
692 [global::__DynamicallyInvokable]
693 public override string[]
AllKeys 695 [global::__DynamicallyInvokable]
698 NormalizeCommonHeaders();
699 return InnerCollection.
AllKeys;
703 private void NormalizeCommonHeaders()
705 if (m_CommonHeaders ==
null)
709 for (
int i = 0; i < m_CommonHeaders.Length; i++)
711 if (m_CommonHeaders[i] !=
null)
713 InnerCollection.
Add(s_CommonHeaderNames[i], m_CommonHeaders[i]);
716 m_CommonHeaders =
null;
717 m_NumCommonHeaders = 0;
727 if (!AllowHttpRequestHeader)
731 Add(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((
int)header), value);
741 if (!AllowHttpResponseHeader)
745 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
749 Add(UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header), value);
759 if (!AllowHttpRequestHeader)
763 Set(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((
int)header), value);
773 if (!AllowHttpResponseHeader)
777 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
781 Set(UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header), value);
786 if (!AllowHttpResponseHeader)
790 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
794 SetInternal(UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header), value);
802 if (!AllowHttpRequestHeader)
806 Remove(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_HEADER_ID.ToString((
int)header));
814 if (!AllowHttpResponseHeader)
818 Remove(UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_HEADER_ID.ToString((
int)header));
831 headerName = CheckBadChars(headerName, isHeaderValue:
false);
832 headerValue = CheckBadChars(headerValue, isHeaderValue:
true);
833 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && headerValue !=
null && headerValue.Length > 65535)
837 NormalizeCommonHeaders();
839 InnerCollection.
Add(headerName, headerValue);
842 internal void SetAddVerified(
string name,
string value)
844 if (HInfo[name].AllowMultiValues)
846 NormalizeCommonHeaders();
848 InnerCollection.
Add(name, value);
852 NormalizeCommonHeaders();
854 InnerCollection.
Set(name, value);
858 internal void AddInternal(
string name,
string value)
860 NormalizeCommonHeaders();
862 InnerCollection.
Add(name, value);
865 internal void ChangeInternal(
string name,
string value)
867 NormalizeCommonHeaders();
869 InnerCollection.
Set(name, value);
872 internal void RemoveInternal(
string name)
874 NormalizeCommonHeaders();
875 if (m_InnerCollection !=
null)
878 m_InnerCollection.
Remove(name);
882 internal void CheckUpdate(
string name,
string value)
884 value = CheckBadChars(value, isHeaderValue:
true);
885 ChangeInternal(name, value);
888 private void AddInternalNotCommon(
string name,
string value)
891 InnerCollection.
Add(name, value);
894 internal static string CheckBadChars(
string name,
bool isHeaderValue)
896 if (name ==
null || name.Length == 0)
900 throw (name ==
null) ?
new ArgumentNullException(
"name") : new ArgumentException(SR.GetString(
"net_emptystringcall",
"name"),
"name");
906 name = name.Trim(HttpTrimCharacters);
908 for (
int i = 0; i < name.Length; i++)
910 char c = (char)(0xFF & name[i]);
922 else if (c ==
'\u007f' || (c <
' ' && c !=
'\t'))
924 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidControlChars"),
"value");
933 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidCRLFChars"),
"value");
935 if (c ==
' ' || c ==
'\t')
940 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidCRLFChars"),
"value");
945 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidCRLFChars"),
"value");
950 if (name.IndexOfAny(ValidationHelper.InvalidParamChars) != -1)
952 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidHeaderChars"),
"name");
954 if (ContainsNonAsciiChars(name))
956 throw new ArgumentException(SR.GetString(
"net_WebHeaderInvalidNonAsciiChars"),
"name");
962 internal static bool IsValidToken(
string token)
964 if (token.Length > 0 && token.IndexOfAny(ValidationHelper.InvalidParamChars) == -1)
966 return !ContainsNonAsciiChars(token);
971 internal static bool ContainsNonAsciiChars(
string token)
973 for (
int i = 0; i < token.Length; i++)
975 if (token[i] <
' ' || token[i] >
'~')
983 internal void ThrowOnRestrictedHeader(
string headerName)
985 if (m_Type == WebHeaderCollectionType.HttpWebRequest)
987 if (HInfo[headerName].IsRequestRestricted)
989 throw new ArgumentException(SR.GetString(
"net_headerrestrict", headerName),
"name");
992 else if (m_Type == WebHeaderCollectionType.HttpListenerResponse && HInfo[headerName].IsResponseRestricted)
994 throw new ArgumentException(SR.GetString(
"net_headerrestrict", headerName),
"name");
1006 public override void Add(
string name,
string value)
1008 name = CheckBadChars(name, isHeaderValue:
false);
1009 ThrowOnRestrictedHeader(name);
1010 value = CheckBadChars(value, isHeaderValue:
true);
1011 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
1015 NormalizeCommonHeaders();
1017 InnerCollection.
Add(name, value);
1028 public void Add(
string header)
1030 if (ValidationHelper.IsBlankString(header))
1034 int num = header.IndexOf(
':');
1037 throw new ArgumentException(SR.GetString(
"net_WebHeaderMissingColon"),
"header");
1039 string name = header.Substring(0, num);
1040 string name2 = header.Substring(num + 1);
1041 name = CheckBadChars(name, isHeaderValue:
false);
1042 ThrowOnRestrictedHeader(name);
1043 name2 = CheckBadChars(name2, isHeaderValue:
true);
1044 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && name2 !=
null && name2.Length > 65535)
1048 NormalizeCommonHeaders();
1050 InnerCollection.
Add(name, name2);
1062 public override void Set(
string name,
string value)
1064 if (ValidationHelper.IsBlankString(name))
1068 name = CheckBadChars(name, isHeaderValue:
false);
1069 ThrowOnRestrictedHeader(name);
1070 value = CheckBadChars(value, isHeaderValue:
true);
1071 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
1075 NormalizeCommonHeaders();
1077 InnerCollection.
Set(name, value);
1080 internal void SetInternal(
string name,
string value)
1082 if (ValidationHelper.IsBlankString(name))
1086 name = CheckBadChars(name, isHeaderValue:
false);
1087 value = CheckBadChars(value, isHeaderValue:
true);
1088 if (m_Type == WebHeaderCollectionType.HttpListenerResponse && value !=
null && value.Length > 65535)
1092 NormalizeCommonHeaders();
1094 InnerCollection.
Set(name, value);
1104 [global::__DynamicallyInvokable]
1107 if (ValidationHelper.IsBlankString(name))
1111 ThrowOnRestrictedHeader(name);
1112 name = CheckBadChars(name, isHeaderValue:
false);
1113 NormalizeCommonHeaders();
1114 if (m_InnerCollection !=
null)
1117 m_InnerCollection.
Remove(name);
1126 NormalizeCommonHeaders();
1127 HeaderInfo headerInfo = HInfo[header];
1128 string[] values = InnerCollection.
GetValues(header);
1129 if (headerInfo ==
null || values ==
null || !headerInfo.AllowMultiValues)
1134 for (
int i = 0; i < values.Length; i++)
1136 string[] array = headerInfo.Parser(values[i]);
1137 if (arrayList ==
null)
1139 if (array.Length > 1)
1151 if (arrayList !=
null)
1153 string[] array2 =
new string[arrayList.
Count];
1154 arrayList.
CopyTo(array2);
1162 [global::__DynamicallyInvokable]
1165 return GetAsString(
this, winInetCompat:
false, forTrace:
false);
1168 internal string ToString(
bool forTrace)
1170 return GetAsString(
this, winInetCompat:
false, forTrace:
true);
1173 internal static string GetAsString(
NameValueCollection cc,
bool winInetCompat,
bool forTrace)
1175 if (cc ==
null || cc.
Count == 0)
1180 string text = cc[
string.Empty];
1185 for (
int i = 0; i < cc.
Count; i++)
1187 string key = cc.
GetKey(i);
1188 string value = cc.
Get(i);
1189 if (!ValidationHelper.IsBlankString(key))
1191 stringBuilder.
Append(key);
1194 stringBuilder.
Append(
':');
1198 stringBuilder.
Append(
": ");
1205 stringBuilder.
Append(
"\r\n");
1215 return HeaderEncoding.GetBytes(myString);
1244 return HInfo[CheckBadChars(headerName, isHeaderValue:
false)].IsRequestRestricted;
1246 return HInfo[CheckBadChars(headerName, isHeaderValue:
false)].IsResponseRestricted;
1250 [global::__DynamicallyInvokable]
1260 if (type == WebHeaderCollectionType.HttpWebResponse)
1262 m_CommonHeaders =
new string[s_CommonHeaderNames.Length - 1];
1267 : base(DBNull.Value)
1270 int count = cc.
Count;
1271 for (
int i = 0; i < count; i++)
1273 string key = cc.
GetKey(i);
1277 for (
int j = 0; j < values.Length; j++)
1279 InnerCollection.
Add(key, values[j]);
1284 InnerCollection.
Add(key,
null);
1299 int @
int = serializationInfo.
GetInt32(
"Count");
1300 m_InnerCollection =
new NameValueCollection(@
int + 2, CaseInsensitiveAscii.StaticInstance);
1301 for (
int i = 0; i < @int; i++)
1305 InnerCollection.
Add(@
string, string2);
1321 NormalizeCommonHeaders();
1323 for (
int i = 0; i <
Count; i++)
1330 internal unsafe DataParseStatus ParseHeaders(
byte[] buffer,
int size, ref
int unparsed, ref
int totalResponseHeadersLength,
int maximumResponseHeadersLength, ref WebParseError parseError)
1332 fixed (
byte* ptr = buffer)
1334 if (buffer.Length < size)
1336 return DataParseStatus.NeedMoreData;
1343 int num6 = unparsed;
1344 int num7 = totalResponseHeadersLength;
1345 WebParseErrorCode code = WebParseErrorCode.Generic;
1346 DataParseStatus dataParseStatus = DataParseStatus.Invalid;
1349 string text =
string.Empty;
1350 string text2 =
string.Empty;
1352 string text3 =
null;
1358 c = (char)ptr[num6];
1359 if (c !=
' ' && c !=
'\t')
1364 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1372 dataParseStatus = DataParseStatus.NeedMoreData;
1379 c = (char)ptr[num6];
1380 if (c !=
':' && c !=
'\n')
1387 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1397 dataParseStatus = DataParseStatus.DataTooBig;
1400 dataParseStatus = DataParseStatus.NeedMoreData;
1403 dataParseStatus = DataParseStatus.DataTooBig;
1406 dataParseStatus = DataParseStatus.DataTooBig;
1409 dataParseStatus = DataParseStatus.NeedMoreData;
1412 if (num >= 0 && num2 >= num)
1414 text = HeaderEncoding.GetString(ptr + num, num2 - num + 1);
1416 if (text.Length > 0)
1418 AddInternal(text, text3);
1420 totalResponseHeadersLength = num7;
1424 dataParseStatus = DataParseStatus.Done;
1429 dataParseStatus = DataParseStatus.DataTooBig;
1435 if (maximumResponseHeadersLength >= 0 && ++num7 >= maximumResponseHeadersLength)
1437 dataParseStatus = DataParseStatus.DataTooBig;
1443 dataParseStatus = DataParseStatus.DataTooBig;
1446 dataParseStatus = DataParseStatus.NeedMoreData;
1449 dataParseStatus = DataParseStatus.DataTooBig;
1454 dataParseStatus = DataParseStatus.NeedMoreData;
1460 num5 = ((
Count == 0 && num2 < 0) ? 1 : 0);
1461 while (num6 < size && num5 < 2)
1463 c = (char)ptr[num6];
1473 if (num6 + 1 == size)
1477 flag = (ptr[num6 + 1] == 32 || ptr[num6 + 1] == 9);
1481 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1487 if (num5 != 2 && (num5 != 1 || flag))
1496 c = (char)ptr[num6];
1506 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1517 while (num6 < size && num5 < 2)
1519 c = (char)ptr[num6];
1520 if (c !=
'\r' && c !=
'\n')
1529 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1535 if (num6 == size && num5 < 2)
1540 if (num3 >= 0 && num3 > num2 && num4 >= num3)
1542 text2 = HeaderEncoding.GetString(ptr + num3, num4 - num3 + 1);
1544 text3 = ((text3 ==
null) ? text2 : (text3 +
" " + text2));
1545 if (num6 < size && num5 == 1)
1547 c = (char)ptr[num6];
1548 if (c ==
' ' || c ==
'\t')
1551 if (maximumResponseHeadersLength < 0 || ++num7 < maximumResponseHeadersLength)
1560 dataParseStatus = DataParseStatus.NeedMoreData;
1564 if (dataParseStatus == DataParseStatus.Invalid)
1566 parseError.Section = WebParseErrorSection.ResponseHeader;
1567 parseError.Code = code;
1569 return dataParseStatus;
1573 internal unsafe DataParseStatus ParseHeadersStrict(
byte[] buffer,
int size, ref
int unparsed, ref
int totalResponseHeadersLength,
int maximumResponseHeadersLength, ref WebParseError parseError)
1575 WebParseErrorCode code = WebParseErrorCode.Generic;
1576 DataParseStatus dataParseStatus = DataParseStatus.Invalid;
1578 int num = (maximumResponseHeadersLength <= 0) ?
int.MaxValue : (maximumResponseHeadersLength - totalResponseHeadersLength + i);
1579 DataParseStatus dataParseStatus2 = DataParseStatus.DataTooBig;
1583 dataParseStatus2 = DataParseStatus.NeedMoreData;
1587 dataParseStatus = dataParseStatus2;
1593 fixed (
byte* ptr = buffer)
1602 dataParseStatus = dataParseStatus2;
1604 else if (ptr[i++] == 10)
1606 totalResponseHeadersLength += i - unparsed;
1608 dataParseStatus = DataParseStatus.Done;
1612 dataParseStatus = DataParseStatus.Invalid;
1613 code = WebParseErrorCode.CrLfError;
1619 for (; i < num; i++)
1622 if ((rfcChar = ((ptr[i] <= 127) ? RfcCharMap[ptr[i]] : RfcChar.High)) != RfcChar.Reg)
1629 dataParseStatus = dataParseStatus2;
1633 dataParseStatus = DataParseStatus.Invalid;
1634 code = WebParseErrorCode.InvalidHeaderName;
1643 if (i < num && (rfcChar = ((ptr[i] <= 127) ? RfcCharMap[ptr[i]] : RfcChar.High)) != RfcChar.Colon)
1669 dataParseStatus = DataParseStatus.Invalid;
1670 code = WebParseErrorCode.CrLfError;
1674 dataParseStatus = dataParseStatus2;
1678 dataParseStatus = DataParseStatus.Invalid;
1679 code = WebParseErrorCode.IncompleteHeaderLine;
1681 else if (++i == num)
1683 dataParseStatus = dataParseStatus2;
1692 if (i < num && ((rfcChar = ((ptr[i] <= 127) ? RfcCharMap[ptr[i]] : RfcChar.High)) == RfcChar.WS || num5 != 2))
1733 string @
string = HeaderEncoding.GetString(ptr + num6, num7 - num6 + 1);
1734 if (stringBuilder ==
null)
1736 stringBuilder =
new StringBuilder(@
string, @
string.Length * 5);
1740 stringBuilder.
Append(
" ");
1741 stringBuilder.
Append(@
string);
1755 dataParseStatus = DataParseStatus.Invalid;
1756 code = WebParseErrorCode.CrLfError;
1761 dataParseStatus = dataParseStatus2;
1764 string text = (num6 == -1) ?
"" : HeaderEncoding.GetString(ptr + num6, num7 - num6 + 1);
1765 if (stringBuilder !=
null)
1767 if (text.Length != 0)
1769 stringBuilder.
Append(
" ");
1770 stringBuilder.
Append(text);
1774 string text2 =
null;
1775 int num8 = num4 - num3 + 1;
1776 if (m_CommonHeaders !=
null)
1778 int num9 = s_CommonHeaderHints[ptr[num3] & 0x1F];
1783 string text3 = s_CommonHeaderNames[num9++];
1784 if (text3.Length < num8 || CaseInsensitiveAscii.AsciiToLower[ptr[num3]] != CaseInsensitiveAscii.AsciiToLower[text3[0]])
1788 if (text3.Length <= num8)
1790 byte* ptr2 = ptr + num3 + 1;
1792 for (j = 1; j < text3.Length; j++)
1794 byte* intPtr = ptr2;
1796 if (*intPtr != text3[j] && CaseInsensitiveAscii.AsciiToLower[*(ptr2 - 1)] != CaseInsensitiveAscii.AsciiToLower[text3[j]])
1801 if (j == text3.Length)
1803 m_NumCommonHeaders++;
1805 if (m_CommonHeaders[num9] ==
null)
1807 m_CommonHeaders[num9] = text;
1811 NormalizeCommonHeaders();
1812 AddInternalNotCommon(text3, text);
1823 text2 = HeaderEncoding.GetString(ptr + num3, num8);
1824 AddInternalNotCommon(text2, text);
1826 totalResponseHeadersLength += i - unparsed;
1847 if (dataParseStatus == DataParseStatus.Invalid)
1849 parseError.Section = WebParseErrorSection.ResponseHeader;
1850 parseError.Code = code;
1852 return dataParseStatus;
1867 public override string Get(
string name)
1869 if (m_CommonHeaders !=
null && name !=
null && name.Length > 0 && name[0] <
'Ā')
1871 int num = s_CommonHeaderHints[name[0] & 0x1F];
1876 string text = s_CommonHeaderNames[num++];
1877 if (text.Length < name.Length || CaseInsensitiveAscii.AsciiToLower[name[0]] != CaseInsensitiveAscii.AsciiToLower[text[0]])
1881 if (text.Length <= name.Length)
1884 for (i = 1; i < text.Length && (name[i] == text[i] || (name[i] <=
'ÿ' && CaseInsensitiveAscii.AsciiToLower[name[i]] == CaseInsensitiveAscii.AsciiToLower[text[i]])); i++)
1887 if (i == text.Length)
1889 return m_CommonHeaders[num - 1];
1895 if (m_InnerCollection ==
null)
1899 return m_InnerCollection.
Get(name);
1906 NormalizeCommonHeaders();
1907 return new NameObjectKeysEnumerator(InnerCollection);
1910 internal override bool InternalHasKeys()
1912 NormalizeCommonHeaders();
1913 if (m_InnerCollection ==
null)
1917 return m_InnerCollection.
HasKeys();
1926 public override string Get(
int index)
1928 NormalizeCommonHeaders();
1929 return InnerCollection.
Get(index);
1937 NormalizeCommonHeaders();
1938 return InnerCollection.
GetValues(index);
1949 NormalizeCommonHeaders();
1950 return InnerCollection.
GetKey(index);
1956 m_CommonHeaders =
null;
1957 m_NumCommonHeaders = 0;
1959 if (m_InnerCollection !=
null)
1961 m_InnerCollection.
Clear();
Represents a character encoding.To browse the .NET Framework source code for this type,...
virtual string Get(string name)
Gets the values associated with the specified key from the T:System.Collections.Specialized....
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
unsafe string GetString(byte *bytes, int byteCount)
When overridden in a derived class, decodes a specified number of bytes starting at a specified addre...
Represents a collection of associated T:System.String keys and T:System.String values that can be acc...
virtual void Clear()
Invalidates the cached arrays and removes all entries from the T:System.Collections....
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
bool HasKeys()
Gets a value indicating whether the T:System.Collections.Specialized.NameValueCollection contains key...
virtual string [] AllKeys
Gets all the keys in the T:System.Collections.Specialized.NameValueCollection.
virtual void Remove(string name)
Removes the entries with the specified key from the T:System.Collections.Specialized....
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
static DecoderFallback ExceptionFallback
Gets an object that throws an exception when an input byte sequence cannot be decoded.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
static Encoding GetEncoding(int codepage)
Returns the encoding associated with the specified code page identifier.
Provides a failure-handling mechanism, called a fallback, for an input character that cannot be conve...
SecurityAction
Specifies the security actions that can be performed using declarative security.
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
void AddValue(string name, object value, Type type)
Adds a value into the T:System.Runtime.Serialization.SerializationInfo store, where value is associa...
virtual string [] GetValues(string name)
Gets the values associated with the specified key from the T:System.Collections.Specialized....
virtual void AddRange(ICollection c)
Adds the elements of an T:System.Collections.ICollection to the end of the T:System....
HttpRequestHeader
The HTTP headers that may be specified in a client request.
virtual string GetKey(int index)
Gets the key at the specified index of the T:System.Collections.Specialized.NameValueCollection.
virtual void Set(string name, string value)
Sets the value of an entry in the T:System.Collections.Specialized.NameValueCollection.
Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that can...
virtual KeysCollection Keys
Gets a T:System.Collections.Specialized.NameObjectCollectionBase.KeysCollection instance that contain...
virtual void CopyTo(Array array)
Copies the entire T:System.Collections.ArrayList to a compatible one-dimensional T:System....
virtual void RemoveRange(int index, int count)
Removes a range of elements from the T:System.Collections.ArrayList.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
The exception that is thrown when one of the arguments provided to a method is not valid.
void InvalidateCachedArrays()
Resets the cached arrays of the collection to null.
Allows an object to control its own serialization and deserialization.
string GetString(string name)
Retrieves a T:System.String value from the T:System.Runtime.Serialization.SerializationInfo store.
Specifies that the class can be serialized.
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Specialized....
The exception that is thrown when a method call is invalid for the object's current state.
int GetInt32(string name)
Retrieves a 32-bit signed integer value from the T:System.Runtime.Serialization.SerializationInfo sto...
static EncoderFallback ExceptionFallback
Gets an object that throws an exception when an input character cannot be encoded.
void Add(NameValueCollection c)
Copies the entries in the specified T:System.Collections.Specialized.NameValueCollection to the curre...
SecurityPermissionFlag
Specifies access flags for the security permission object.
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Supports a simple iteration over a non-generic collection.
HttpResponseHeader
The HTTP headers that can be specified in a server response.
NameValueCollection()
Initializes a new instance of the T:System.Collections.Specialized.NameValueCollection class that is ...
Represents a nonexistent value. This class cannot be inherited.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...