internal OwinListenerContext(ConnectionInfo listenerContext, IRequestMessage request) { _listenerContext = listenerContext; _environment = new CallEnvironment { { Constants.RequestScheme, "" },//Uri.UriSchemeHttp { Constants.RequestMethod, "" }, { Constants.RequestPathBase, "" }, { Constants.RequestPath, "" }, { Constants.RequestQueryString, "" }, { Constants.RequestProtocol, "" }, { Constants.RequestHeaders, new RequestHeadersDictionary(request) }, { Constants.RequestBody, new ListenerStreamWrapper(request.InputStream) }, { Constants.ResponseStatusCode, (int)HttpStatusCode.OK }, { Constants.ResponseBody, new ListenerStreamWrapper(new MemoryStream()) }, { Constants.ResponseHeaders, new ResponseHeadersDictionary() }, { Constants.OwinVersion, "" }, { Constants.CallCancelled, GetCallCancelled() }, { Constants.CommonKeys.RemoteIpAddress, "" }, { Constants.CommonKeys.RemotePort, "" }, { Constants.CommonKeys.LocalIpAddress, "" }, { Constants.CommonKeys.LocalPort, "" }, { Constants.CommonKeys.IsLocal, "" } }; var user = new ClaimsPrincipal(); var Identity = new ClaimsIdentity("session"); Identity.AddClaim(new Claim(ClaimTypes.Sid, _listenerContext.SessionId)); user.AddIdentity(Identity); _environment.Add(Constants.Security.User, user); }
internal OwinHttpListenerContext(HttpListenerContext context, string basePath, string path, string query) { _environment = new CallEnvironment(this); _owinRequest = new OwinHttpListenerRequest(context, basePath, path, query, _environment); _owinResponse = new OwinHttpListenerResponse(context, _environment); _environment.OwinVersion = Constants.OwinVersion; SetServerUser(context.User); _environment.RequestContext = context; }
/// <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) { _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(SResponseBodyStarted, this); _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="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(HttpListenerContext context, string basePath, string path, string query, CallEnvironment environment) { Contract.Requires(context != null); _context = context; _request = context.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.RequestId = request.RequestTraceIdentifier.ToString(); _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>)LoadClientCert; } }
private void PopulateServerKeys(CallEnvironment environment) { environment.Add(Constants.RequestServiceKey, this.serviceprovider); }
private void PopulateServerKeys(CallEnvironment env) { env.ServerCapabilities = _capabilities; env.Listener = _listener; env.OwinHttpListener = this; }