当前位置: 首页>>代码示例>>C#>>正文


C# HttpWebRequest.EndWriteHeaders方法代码示例

本文整理汇总了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;
        }
开发者ID:ArildF,项目名称:masters,代码行数:64,代码来源:_connectstream.cs


注:本文中的System.Net.HttpWebRequest.EndWriteHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。