本文整理汇总了C#中DataReader.ReadToEnd方法的典型用法代码示例。如果您正苦于以下问题:C# DataReader.ReadToEnd方法的具体用法?C# DataReader.ReadToEnd怎么用?C# DataReader.ReadToEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataReader
的用法示例。
在下文中一共展示了DataReader.ReadToEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromStream
public void FromStream(DataReader reader, StateDictionary state, Utils.Logger logger)
{
Bytes = reader.ReadToEnd();
}
示例2: HTTPData
public HTTPData(DataReader stm, Logger logger)
{
string header = stm.ReadLine();
int contentLength = -1;
bool chunked = false;
byte[] body = null;
bool connClose = false;
if (header.Length == 0)
{
throw new EndOfStreamException();
}
HttpVersion ver = OnReadHeader(header.Trim(), logger);
ReadHeaders(stm, logger);
foreach (KeyDataPair<string> value in Headers)
{
if (value.Name.Equals("content-length", StringComparison.OrdinalIgnoreCase))
{
contentLength = int.Parse(value.Value.ToString());
break;
}
else if (value.Name.Equals("transfer-encoding", StringComparison.OrdinalIgnoreCase))
{
if (value.Value.ToString().Equals("chunked", StringComparison.OrdinalIgnoreCase))
{
chunked = true;
break;
}
}
else if (value.Name.Equals("connection", StringComparison.OrdinalIgnoreCase))
{
// If the server indicates it will close the connection afterwards
if (value.Value.ToString().Equals("close", StringComparison.OrdinalIgnoreCase))
{
connClose = true;
}
}
}
body = new byte[0];
if (CanHaveBody())
{
if (chunked)
{
List<byte> bodyData = new List<byte>();
byte[] data = ReadChunk(stm, logger);
while (data.Length > 0)
{
bodyData.AddRange(data);
data = ReadChunk(stm, logger);
}
body = bodyData.ToArray();
}
else if (contentLength > 0)
{
body = stm.ReadBytes(contentLength);
}
else if ((contentLength < 0) && ((ver == HttpVersion.Http1_0) || connClose) && !IsRequest)
{
// HTTP1.0 waits till end of stream (need to only do this on response though)
// Also sometimes happen on v1.1 if the client indicates that it is closing the connection
body = stm.ReadToEnd();
}
}
Body = body;
}