本文整理汇总了C#中System.Net.WebHeaderCollection.ParseHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.ParseHeaders方法的具体用法?C# WebHeaderCollection.ParseHeaders怎么用?C# WebHeaderCollection.ParseHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.ParseHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseTrailer
private DataParseStatus ParseTrailer()
{
if (ParseWhitespaces(ref bufferCurrentPos) == DataParseStatus.NeedMoreData)
{
return DataParseStatus.NeedMoreData;
}
int currentPos = bufferCurrentPos;
// Leverage WebHeaderCollection to parse the trailer.
DataParseStatus result;
WebParseError error;
error.Section = WebParseErrorSection.Generic;
error.Code = WebParseErrorCode.Generic;
WebHeaderCollection trailer = new WebHeaderCollection();
if (SettingsSectionInternal.Section.UseUnsafeHeaderParsing)
{
result = trailer.ParseHeaders(buffer, bufferFillLength, ref currentPos, ref totalTrailerHeadersLength,
maxBufferLength, ref error);
}
else
{
result = trailer.ParseHeadersStrict(buffer, bufferFillLength, ref currentPos,
ref totalTrailerHeadersLength, maxBufferLength, ref error);
}
Contract.Assert(result != DataParseStatus.ContinueParsing,
"ContinueParsing should never be returned by WebHeaderCollection.ParseHeaders*().");
if ((result == DataParseStatus.NeedMoreData) || (result == DataParseStatus.Done))
{
bufferCurrentPos = currentPos;
}
if (result != DataParseStatus.Done)
{
return result;
}
readState = ReadState.Done;
// We're done reading the whole response. Invoke the user callback with 0 bytes to indicate "end of stream".
CompleteUserRead(0);
return DataParseStatus.Done;
}