示例#1
0
        internal OwinHttpListenerContext(HttpListenerContext httpListenerContext, string basePath, string path, string query)
        {
            _httpListenerContext = httpListenerContext;
            _environment = new CallEnvironment(this);
            _owinRequest = new OwinHttpListenerRequest(_httpListenerContext.Request, basePath, path, query, _environment);
            _owinResponse = new OwinHttpListenerResponse(_httpListenerContext, _environment);

            _environment.OwinVersion = Constants.OwinVersion;

            _environment.ServerUser = _httpListenerContext.User;
        }
        internal OwinHttpListenerContext(HttpListenerContext httpListenerContext, string basePath, string path, string query, DisconnectHandler disconnectHandler)
        {
            _httpListenerContext = httpListenerContext;
            _environment         = new CallEnvironment(this);
            _owinRequest         = new OwinHttpListenerRequest(_httpListenerContext.Request, basePath, path, query, _environment);
            _owinResponse        = new OwinHttpListenerResponse(_httpListenerContext, _environment);
            _disconnectHandler   = disconnectHandler;

            _environment.OwinVersion = Constants.OwinVersion;

            SetServerUser(_httpListenerContext.User);
            _environment.RequestContext = _httpListenerContext;
        }
        internal OwinHttpListenerContext(HttpListenerContext httpListenerContext, string basePath, string path, string query, DisconnectHandler disconnectHandler)
        {
            _httpListenerContext = httpListenerContext;
            _environment = new CallEnvironment(this);
            _owinRequest = new OwinHttpListenerRequest(_httpListenerContext.Request, basePath, path, query, _environment);
            _owinResponse = new OwinHttpListenerResponse(_httpListenerContext, _environment);
            _disconnectHandler = disconnectHandler;

            _environment.OwinVersion = Constants.OwinVersion;

            SetServerUser(_httpListenerContext.User);
            _environment.RequestContext = _httpListenerContext;
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerResponse"/> class.
        /// Sets up the Environment with the necessary request state items.
        /// </summary>
        internal OwinHttpListenerResponse(HttpListenerContext context, CallEnvironment environment)
        {
            Contract.Requires(context != null);
            Contract.Requires(environment != null);
            _context = context;
            _response = _context.Response;
            _environment = environment;

            _requestState = RequestInProgress;

            var outputStream = new HttpListenerStreamWrapper(_response.OutputStream);
            outputStream.OnFirstWrite = ResponseBodyStarted;
            _environment.ResponseBody = outputStream;

            _environment.ResponseHeaders = new ResponseHeadersDictionary(_response);

            _onSendingHeadersActions = new List<Tuple<Action<object>, object>>();
            _environment.OnSendingHeaders = RegisterForOnSendingHeaders;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerResponse"/> class.
        /// Sets up the Environment with the necessary request state items.
        /// </summary>
        internal OwinHttpListenerResponse(HttpListenerContext context, CallEnvironment environment)
        {
            Contract.Requires(context != null);
            Contract.Requires(environment != null);
            _context     = context;
            _response    = _context.Response;
            _environment = environment;

            _requestState = RequestInProgress;

            var outputStream = new HttpListenerStreamWrapper(_response.OutputStream);

            outputStream.OnFirstWrite = ResponseBodyStarted;
            _environment.ResponseBody = outputStream;

            _environment.ResponseHeaders = new ResponseHeadersDictionary(_response);

            _onSendingHeadersActions      = new List <Tuple <Action <object>, object> >();
            _environment.OnSendingHeaders = RegisterForOnSendingHeaders;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerResponse"/> class.
        /// Sets up the Environment with the necessary request state items.
        /// </summary>
        internal OwinHttpListenerResponse(HttpListenerContext context, CallEnvironment environment)
        {
            Contract.Requires(context != null);
            Contract.Requires(environment != null);
            _context = context;
            _response = _context.Response;
            _environment = environment;

            _requestState = RequestInProgress;

            // Provide the default status code for consistency with SystemWeb, even though it's optional.
            _environment.ResponseStatusCode = (int)HttpStatusCode.OK; // 200

            var outputStream = new HttpListenerStreamWrapper(_response.OutputStream);
            outputStream.OnFirstWrite(_responseBodyStarted, this);
            _environment.ResponseBody = outputStream;

            _environment.ResponseHeaders = new ResponseHeadersDictionary(_response);

            _onSendingHeadersActions = new List<Tuple<Action<object>, object>>();
            _environment.OnSendingHeaders = RegisterForOnSendingHeaders;
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerRequest"/> class.
        /// Uses the given request object to populate the OWIN standard keys in the environment IDictionary.
        /// Most values are copied so that they can be mutable, but the headers collection is only wrapped.
        /// </summary>
        internal OwinHttpListenerRequest(HttpListenerRequest request, string basePath, string path, string query, CallEnvironment environment)
        {
            Contract.Requires(request != null);

            _request = request;
            _environment = environment;

            _environment.RequestProtocol = GetProtocol(request.ProtocolVersion);
            _environment.RequestScheme = request.Url.Scheme;
            _environment.RequestMethod = request.HttpMethod;
            _environment.RequestPathBase = basePath;
            _environment.RequestPath = path;
            _environment.RequestQueryString = query;

            _environment.RequestHeaders = new RequestHeadersDictionary(request);

            if (_request.IsSecureConnection)
            {
                // TODO: Add delay sync load for folks that directly access the client cert key
                _environment.LoadClientCert = (Func<Task>)LoadClientCertAsync;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerRequest"/> class.
        /// Uses the given request object to populate the OWIN standard keys in the environment IDictionary.
        /// Most values are copied so that they can be mutable, but the headers collection is only wrapped.
        /// </summary>
        internal OwinHttpListenerRequest(HttpListenerRequest request, string basePath, string path, string query, CallEnvironment environment)
        {
            Contract.Requires(request != null);

            _request     = request;
            _environment = environment;

            _environment.RequestProtocol    = GetProtocol(request.ProtocolVersion);
            _environment.RequestScheme      = request.IsSecureConnection ? Uri.UriSchemeHttps : Uri.UriSchemeHttp;
            _environment.RequestMethod      = request.HttpMethod;
            _environment.RequestPathBase    = basePath;
            _environment.RequestPath        = path;
            _environment.RequestQueryString = query;

            _environment.RequestHeaders = new RequestHeadersDictionary(request);

            if (_request.IsSecureConnection)
            {
                // TODO: Add delay sync load for folks that directly access the client cert key
                _environment.LoadClientCert = (Func <Task>)LoadClientCertAsync;
            }
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OwinHttpListenerResponse"/> class.
        /// Sets up the Environment with the necessary request state items.
        /// </summary>
        internal OwinHttpListenerResponse(HttpListenerContext context, CallEnvironment environment)
        {
            Contract.Requires(context != null);
            Contract.Requires(environment != null);
            _context     = context;
            _response    = _context.Response;
            _environment = environment;

            _requestState = RequestInProgress;

            // Provide the default status code for consistency with SystemWeb, even though it's optional.
            _environment.ResponseStatusCode = (int)HttpStatusCode.OK; // 200

            var outputStream = new HttpListenerStreamWrapper(_response.OutputStream);

            outputStream.OnFirstWrite(_responseBodyStarted, this);
            _environment.ResponseBody = outputStream;

            _environment.ResponseHeaders = new ResponseHeadersDictionary(_response);

            _onSendingHeadersActions      = new List <Tuple <Action <object>, object> >();
            _environment.OnSendingHeaders = RegisterForOnSendingHeaders;
        }
示例#10
0
 private void PopulateServerKeys(CallEnvironment env)
 {
     env.ServerCapabilities = _capabilities;
     env.Listener = _listener;
     env.OwinHttpListener = this;
 }
示例#11
0
 private void PopulateServerKeys(CallEnvironment env)
 {
     env.ServerCapabilities = _capabilities;
 }