Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public Task<IRequest> BeginRequest(ISocket socket)
 {
     return socket.BufferHeaders().ContinueWith(t => KayakRequest.CreateRequest(socket, t.Result));
 }
Ejemplo n.º 3
0
        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);
        }