Example #1
0
        public Task Invoke(IDictionary<string, object> env)
        {
            var serverRequest = new ServerRequest(env);
            var serverResponse = new ServerResponse(env);
            var hostContext = new HostContext(serverRequest, serverResponse);

            var origins = serverRequest.RequestHeaders.GetHeaders("Origin");
            if (origins != null && origins.Any(origin => !String.IsNullOrEmpty(origin)))
            {
                serverResponse.ResponseHeaders["Access-Control-Allow-Origin"] = origins;
                serverResponse.ResponseHeaders["Access-Control-Allow-Credentials"] = AllowCredentialsTrue;
            }

            hostContext.Items[HostConstants.SupportsWebSockets] = env.ContainsKey(OwinConstants.WebSocketSupport);

            serverRequest.DisableRequestBuffering();
            serverResponse.DisableResponseBuffering();

            _connection.Initialize(_resolver, hostContext);

            return _connection.ProcessRequestAsync(hostContext);
        }
        public Task Invoke(IDictionary <string, object> env)
        {
            var serverRequest  = new ServerRequest(env);
            var serverResponse = new ServerResponse(env);
            var hostContext    = new HostContext(serverRequest, serverResponse);

            var origins = serverRequest.RequestHeaders.GetHeaders("Origin");

            if (origins != null && origins.Any(origin => !String.IsNullOrEmpty(origin)))
            {
                serverResponse.ResponseHeaders["Access-Control-Allow-Origin"]      = origins;
                serverResponse.ResponseHeaders["Access-Control-Allow-Credentials"] = AllowCredentialsTrue;
            }

            hostContext.Items[HostConstants.SupportsWebSockets] = env.ContainsKey(OwinConstants.WebSocketSupport);

            serverRequest.DisableRequestBuffering();
            serverResponse.DisableResponseBuffering();

            _connection.Initialize(_resolver, hostContext);

            return(_connection.ProcessRequestAsync(hostContext));
        }