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


C# WebHeaderCollection.Get方法代码示例

本文整理汇总了C#中WebHeaderCollection.Get方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.Get方法的具体用法?C# WebHeaderCollection.Get怎么用?C# WebHeaderCollection.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebHeaderCollection的用法示例。


在下文中一共展示了WebHeaderCollection.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Get_Success

        public void Get_Success()
        {
            string[] keys = { "Accept", "uPgRaDe", "Custom" };
            string[] values = { "text/plain, text/html", " HTTP/2.0 , SHTTP/1.3,  , RTA/x11 ", "\"xyzzy\", \"r2d2xxxx\", \"c3piozzzz\"" };
            WebHeaderCollection w = new WebHeaderCollection();

            for (int i = 0; i < keys.Length; ++i)
            {
                w.Add(keys[i], values[i]);
            }

            for (int i = 0; i < keys.Length; ++i)
            {
                string expected = values[i].Trim();
                Assert.Equal(expected, w.Get(i));
            }
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:17,代码来源:WebHeaderCollectionTest.cs

示例2: Get_Fail

        public void Get_Fail()
        {
            WebHeaderCollection w = new WebHeaderCollection();
            w.Add("Accept", "text/plain");

            Assert.Throws<ArgumentOutOfRangeException>(() => w.Get(-1));
            Assert.Throws<ArgumentOutOfRangeException>(() => w.Get(42));
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:8,代码来源:WebHeaderCollectionTest.cs

示例3: ExecRequest

    public Hashtable ExecRequest( string Cmd, string ContentType,
                                  string Content, WebHeaderCollection hds,
                                  bool GetResponse )
    {
        byte [] buf;
        string line;

        string req = String.Format(
            "{0} {1} RTSP/1.0\r\n" + "CSeq: {2}\r\n",
            Cmd, url, ++cseq );

        if( session != null )
            req += String.Format( "Session: {0}\r\n", session );

        if( hds != null )
        {
            for( int i = 0; i < hds.Count; i++ )
            {
                req += String.Format( "{0}: {1}\r\n",
                    hds.GetKey( i ), hds.Get( i ) );
            }
        }

        if( ContentType != null && Content != null )
        {
            req += String.Format(
                "Content-Type: {0}\r\n" + "Content-Length: {1}\r\n",
                ContentType, Content.Length );
        }

        req += String.Format( "User-Agent: {0}\r\n", useragent );

        for( int i = 0; i < addheaders.Count; i++ )
        {
            req += String.Format( "{0}: {1}\r\n",
                addheaders.GetKey( i ), addheaders.Get( i ) );
        }

        req += "\r\n";

        if( ContentType != null && Content != null )
            req += Content;

        buf = Encoding.ASCII.GetBytes( req );
        nsctrl.Write( buf, 0, buf.Length );

        if( !GetResponse )
            return null;

        line = srctrl.ReadLine();
        if( line == null || line == "" )
            throw new Exception( "Request failed, read error" );

        string [] tokens = line.Split( new char[] { ' ' } );
        if( tokens.Length != 3 || tokens[ 1 ] != "200" )
            throw new Exception( "Request failed, error " + tokens[ 1 ] );

        string name = null;
        Hashtable ht = new Hashtable();
        while( ( line = srctrl.ReadLine() ) != null && line != "" )
        {
            if( name != null && Char.IsWhiteSpace( line[ 0 ] ) )
            {
                ht[ name ] += line;
                continue;
            }

            int i = line.IndexOf( ":" );
            if( i == -1 )
                throw new Exception( "Request failed, bad header" );

            name = line.Substring( 0, i );
            ht[ name ] = line.Substring( i + 1 ).Trim();
        }

        return ht;
    }
开发者ID:llytvynenko,项目名称:axStream,代码行数:77,代码来源:RTSPClient.cs


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