本文整理汇总了C#中System.Net.HttpWebRequest.EndWriteHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWebRequest.EndWriteHeaders方法的具体用法?C# HttpWebRequest.EndWriteHeaders怎么用?C# HttpWebRequest.EndWriteHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.HttpWebRequest
的用法示例。
在下文中一共展示了HttpWebRequest.EndWriteHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteHeaders
/*++
WriteHeaders
This function writes header data to the network. Headers are special
in that they don't have any non-header transforms applied to them,
and are not subject to content-length constraints. We just write them
through, and if we're done writing headers we tell the connection that.
Input:
httpWebRequest - request whose headers we're about to write.
writeDoneDelegate - delegate we call to find out if we have a write stream.
Returns:
WebExceptionStatus.Pending - we don't have a stream yet.
WebExceptionStatus.SendFailure - there was an error while writing to the wire.
WebExceptionStatus.Success - success.
--*/
internal virtual WebExceptionStatus WriteHeaders(HttpWebRequest httpWebRequest) {
GlobalLog.Enter("ConnectStream#" + ValidationHelper.HashString(this) + "::WriteHeaders", "Connection#" + ValidationHelper.HashString(m_Connection) + ", " + httpWebRequest.WriteBuffer.Length.ToString());
if (ErrorInStream) {
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::WriteHeaders", "ErrorInStream");
return WebExceptionStatus.SendFailure;
}
Interlocked.Increment( ref m_CallNesting );
GlobalLog.Print("Inc: " + m_CallNesting.ToString());
try {
//
// no need to buffer here:
// on resubmit, the headers, which may be changed, will be sent from
// the HttpWebRequest object when calling into this method again.
//
m_Connection.Write(httpWebRequest.WriteBuffer, 0, httpWebRequest.WriteBuffer.Length);
} catch {
IOError();
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::WriteHeaders", "Exception");
return WebExceptionStatus.SendFailure;
}
Interlocked.Decrement( ref m_CallNesting );
GlobalLog.Print("Dec: " + m_CallNesting.ToString());
bool completed = httpWebRequest.EndWriteHeaders();
if (!completed) {
// indicates that we're going pending
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::WriteHeaders", "Pending");
return WebExceptionStatus.Pending;
}
if (BytesLeftToWrite == 0) {
//
// didn't go pending, no data to write. we're done.
//
CallDone();
}
GlobalLog.Leave("ConnectStream#" + ValidationHelper.HashString(this) + "::WriteHeaders", httpWebRequest.WriteBuffer.Length);
return WebExceptionStatus.Success;
}