當前位置: 首頁>>代碼示例>>C#>>正文


C# StringReader.ReadRequestLine方法代碼示例

本文整理匯總了C#中System.IO.StringReader.ReadRequestLine方法的典型用法代碼示例。如果您正苦於以下問題:C# StringReader.ReadRequestLine方法的具體用法?C# StringReader.ReadRequestLine怎麽用?C# StringReader.ReadRequestLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.StringReader的用法示例。


在下文中一共展示了StringReader.ReadRequestLine方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BeginRequestInternal

        public IEnumerable<object> BeginRequestInternal(ISocket socket)
        {
            var bufferHeaders = new ContinuationState<LinkedList<ArraySegment<byte>>>(socket.BufferHeaders());
            yield return bufferHeaders;

            var headerBuffers = bufferHeaders.Result;

            Dictionary<string, object> env = new Dictionary<string, object>();

            var bodyDataReadWithHeaders = headerBuffers.Last.Value;
            headerBuffers.RemoveLast();

            var headersString = headerBuffers.GetString();
            var reader = new StringReader(headersString);
            var requestLine = reader.ReadRequestLine();
            var headers = reader.ReadHeaders();

            env["Owin.RequestMethod"] = requestLine.Verb;
            env["Owin.RequestUri"] = requestLine.RequestUri;
            env["Owin.RequestHeaders"] = headers;
            env["Owin.BaseUri"] = "";
            env["Owin.RemoteEndPoint"] = socket.RemoteEndPoint;
            env["Owin.RequestBody"] = CreateReadBody(socket, bodyDataReadWithHeaders);

            // TODO provide better values
            env["Owin.ServerName"] = "";
            env["Owin.ServerPort"] = 0;
            env["Owin.UriScheme"] = "http";

            yield return env;
        }
開發者ID:lovewitty,項目名稱:OstrichNet,代碼行數:31,代碼來源:HttpSupport.cs

示例2: Begin

        public IObservable<Unit> Begin()
        {
            return Observable.CreateWithDisposable<Unit>(o =>
            {
                // would be nice some day to parse the request with a fancy state machine
                // for lower memory usage.
                Trace.Write("Beginning request.");
                return socket.ReadHeaders().Subscribe(headerBuffers =>
                    {
                        bodyDataReadWithHeaders = headerBuffers.Last.Value;
                        headerBuffers.RemoveLast();

                        var reader = new StringReader(headerBuffers.GetString());

                        this.requestLine = reader.ReadRequestLine();
                        Headers = reader.ReadHeaders();

                        reader.Dispose(); // necessary?
                        Trace.Write("Request began.");
                    },
                    e =>
                    {
                        o.OnError(e);
                    },
                    () =>
                    {
                        o.OnCompleted();
                    });
            });
        }
開發者ID:nithinphilips,項目名稱:bbwifimusicsync,代碼行數:30,代碼來源:KayakServerRequest.cs

示例3: GivenHttpVersion

        public void GivenHttpVersion()
        {
            var reader = new StringReader("asdas df asdf");

            var requestLine = reader.ReadRequestLine();

            Assert.AreEqual("asdf", requestLine.HttpVersion);
        }
開發者ID:purplecow,項目名稱:kayak,代碼行數:8,代碼來源:ParsingTests.cs

示例4: DefaultHttpVersion

        public void DefaultHttpVersion()
        {
            var reader = new StringReader("asdas df");

            var requestLine = reader.ReadRequestLine();

            Assert.AreEqual("HTTP/1.0", requestLine.HttpVersion);
        }
開發者ID:purplecow,項目名稱:kayak,代碼行數:8,代碼來源:ParsingTests.cs

示例5: CreateRequest

        public static IRequest CreateRequest(ISocket socket, LinkedList<ArraySegment<byte>> headerBuffers)
        {
            var bodyDataReadWithHeaders = headerBuffers.Last.Value;
            headerBuffers.RemoveLast();

            var headersString = headerBuffers.GetString();
            var reader = new StringReader(headersString);
            var requestLine = reader.ReadRequestLine();
            var headers = reader.ReadHeaders();
            var context = new Dictionary<string, object>();

            return new KayakRequest(socket, requestLine, headers, context, bodyDataReadWithHeaders);
        }
開發者ID:chakrit,項目名稱:kayak,代碼行數:13,代碼來源:KayakRequest.cs

示例6: MalformedStatusLine4

            public void MalformedStatusLine4()
            {
                var reader = new StringReader("asd asd d fs  aaaa    ");

                reader.ReadRequestLine();
            }
開發者ID:nithinphilips,項目名稱:bbwifimusicsync,代碼行數:6,代碼來源:HttpTests.cs

示例7: MalformedStatusLine3

            public void MalformedStatusLine3()
            {
                var reader = new StringReader("asdasd  fds sd dsfasdf");

                reader.ReadRequestLine();
            }
開發者ID:nithinphilips,項目名稱:bbwifimusicsync,代碼行數:6,代碼來源:HttpTests.cs

示例8: EmptyStatusLine

            public void EmptyStatusLine()
            {
                var reader = new StringReader("");

                reader.ReadRequestLine();
            }
開發者ID:nithinphilips,項目名稱:bbwifimusicsync,代碼行數:6,代碼來源:HttpTests.cs


注:本文中的System.IO.StringReader.ReadRequestLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。