本文整理汇总了C#中System.Net.HttpWebRequest.FinishContinueWait方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWebRequest.FinishContinueWait方法的具体用法?C# HttpWebRequest.FinishContinueWait怎么用?C# HttpWebRequest.FinishContinueWait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.HttpWebRequest
的用法示例。
在下文中一共展示了HttpWebRequest.FinishContinueWait方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyncRead
//.........这里部分代码省略.........
int bytesRead = -1;
WebExceptionStatus errorStatus = WebExceptionStatus.ReceiveFailure;
if (m_BytesScanned < m_BytesRead)
{
// left over from previous read
pollSuccess = true;
bytesRead = 0; //tell it we want to use buffered data on the first iteration
errorStatus = WebExceptionStatus.Success;
}
do {
requestDone = true;
try {
if (bytesRead != 0)
{
errorStatus = WebExceptionStatus.ReceiveFailure;
if (!pollSuccess)
{
pollSuccess = Poll(request.ContinueTimeout * 1000, SelectMode.SelectRead); // Timeout is in microseconds
GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::SyncRead() PollSuccess : " + pollSuccess);
}
if (pollSuccess)
{
//Ensures that we'll timeout eventually on an appdomain unload.
//Will be a no-op if the timeout doesn't change from request to request.
ReadTimeout = request.Timeout;
bytesRead = Read(m_ReadBuffer, m_BytesRead, m_ReadBuffer.Length - m_BytesRead);
errorStatus = WebExceptionStatus.Success;
if (bytesRead == 0)
bytesRead = -1; // 0 is reserved for re-entry on already buffered data
}
}
}
catch (Exception exception)
{
if (NclUtilities.IsFatal(exception)) throw;
if (m_InnerException == null)
m_InnerException = exception;
if (exception.GetType() == typeof(ObjectDisposedException))
errorStatus = WebExceptionStatus.RequestCanceled;
// need to handle SSL errors too
#if !FEATURE_PAL
else if (NetworkStream is TlsStream) {
errorStatus = ((TlsStream)NetworkStream).ExceptionStatus;
}
#endif // !FEATURE_PAL
else
{
SocketException socketException = exception.InnerException as SocketException;
if (socketException != null)
{
if (socketException.ErrorCode == (int) SocketError.TimedOut)
errorStatus = WebExceptionStatus.Timeout;
else
errorStatus = WebExceptionStatus.ReceiveFailure;
}
}
GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::SyncRead() Read() threw errorStatus:" + errorStatus.ToString() + " bytesRead:" + bytesRead.ToString());
}
if (pollSuccess)
requestDone = ReadComplete(bytesRead, errorStatus);
bytesRead = -1;
} while (!requestDone && (userRetrievedStream || requestContinueCount == request.RequestContinueCount));
}
finally {
t_SyncReadNesting--;
}
if (probeRead)
{
// [....] 100-Continue wait only
request.FinishContinueWait();
if (pollSuccess)
{
if (!request.Saw100Continue && !userRetrievedStream)
{
//During polling, we got a response that wasn't a 100 continue.
request.NeedsToReadForResponse = false;
}
}
else
{
GlobalLog.Print("Connection#" + ValidationHelper.HashString(this) + "::SyncRead() Poll has timed out, calling SetRequestContinue().");
request.SetRequestContinue();
}
}
GlobalLog.Leave("Connection#" + ValidationHelper.HashString(this) + "::SyncRead()");
}