public HostingApplication( RequestDelegate application, IHttpContextFactory httpContextFactory) { _application = application; _httpContextFactory = httpContextFactory; }
public RioSharpServer(FeatureCollection features, IApplicationLifetime appLifetime, ILogger logger, IHttpContextFactory httpContextFactory) { Features = features; _appLifetime = appLifetime; _logger = logger; _httpContextFactory = httpContextFactory; }
/// <summary> /// Initializes a new instance of the <see cref="HttpListenerBase"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <param name="certificate">Certificate to use</param> /// <param name="protocol">which HTTPS protocol to use, default is TLS.</param> protected HttpListenerBase( IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, SslProtocols protocol) : this(address, port, factory, certificate) { _sslProtocol = protocol; }
public LocaleInitializer( IContextUtilities contextUtilities, IHttpContextFactory httpContextFactory, IApplicationContext appContext ) { if (contextUtilities == null) { throw new ArgumentNullException("contextUtilities"); } if (httpContextFactory == null) { throw new ArgumentNullException("httpContextFactory"); } if (appContext == null) { throw new ArgumentNullException("appContext"); } this.contextUtilities = contextUtilities; this.httpContextFactory = httpContextFactory; this.appContext = appContext; // Execute on creation GetLocaleFromContext(); }
/// <summary> /// Initializes a new instance of the <see cref="HttpListenerBase"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <param name="certificate">Certificate to use</param> protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate) : this(address, port, factory) { Check.Require(certificate, "certificate"); _certificate = certificate; }
internal RequestState(IHttpRequestFeature requestFeature, IHttpContextFactory factory, IFeatureCollection featureCollection) { _factory = factory; _requestAbortedSource = new CancellationTokenSource(); _pipelineFinished = false; var contextFeatures = new FeatureCollection(featureCollection); contextFeatures.Set(requestFeature); _responseFeature = new ResponseFeature { Protocol = requestFeature.Protocol }; contextFeatures.Set <IHttpResponseFeature>(_responseFeature); var requestLifetimeFeature = new HttpRequestLifetimeFeature(); contextFeatures.Set <IHttpRequestLifetimeFeature>(requestLifetimeFeature); _responseStream = new WriteOnlyResponseStream(AbortRequest); _responseFeature.Body = _responseStream; _responseFeature.StatusCode = 200; requestLifetimeFeature.RequestAborted = _requestAbortedSource.Token; Context = _factory.Create(contextFeatures); }
/// <summary> /// Initializes a new instance of the <see cref="HttpListenerBase"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <param name="certificate">Certificate to use</param> /// <param name="protocol">which HTTPS protocol to use, default is TLS.</param> /// <param name="requireClientCerts">True if client SSL certificates are required, otherwise false</param> protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, SslProtocols protocol, bool requireClientCerts) : this(address, port, factory, certificate) { _requireClientCerts = requireClientCerts; _sslProtocol = protocol; }
/// <summary> /// Listen for regular HTTP connections /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTP port is 80.</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <exception cref="ArgumentNullException"><c>address</c> is null.</exception> /// <exception cref="ArgumentException">Port must be a positive number.</exception> protected OSHttpListener(IPAddress address, int port) { m_address = address; m_port = port; m_contextFactory = new HttpContextFactory(m_logWriter); m_contextFactory.RequestReceived += OnRequestReceived; }
internal RequestState(IHttpRequestFeature requestFeature, IHttpContextFactory factory, IFeatureCollection featureCollection) { _factory = factory; _requestAbortedSource = new CancellationTokenSource(); _pipelineFinished = false; var contextFeatures = new FeatureCollection(featureCollection); contextFeatures.Set(requestFeature); _responseStream = new WriteOnlyResponseStream(AbortRequest); _responseFeature = new ResponseFeature(requestFeature.Protocol, 200, null, _responseStream, new HeaderDictionary()) { Abort = Abort }; contextFeatures.Set <IHttpResponseFeature>(_responseFeature); contextFeatures.Set <IHttpResponseBodyFeature>(new StreamResponseBodyFeature(_responseStream)); var requestLifetimeFeature = new HttpRequestLifetimeFeature(); contextFeatures.Set <IHttpRequestLifetimeFeature>(requestLifetimeFeature); requestLifetimeFeature.RequestAborted = _requestAbortedSource.Token; Context = _factory.Create(contextFeatures); }
public GenericWebHostService(IOptions <GenericWebHostServiceOptions> options, IServer server, ILoggerFactory loggerFactory, DiagnosticListener diagnosticListener, ActivitySource activitySource, DistributedContextPropagator propagator, IHttpContextFactory httpContextFactory, IApplicationBuilderFactory applicationBuilderFactory, IEnumerable <IStartupFilter> startupFilters, IConfiguration configuration, IWebHostEnvironment hostingEnvironment) { Options = options.Value; Server = server; Logger = loggerFactory.CreateLogger("Microsoft.AspNetCore.Hosting.Diagnostics"); LifetimeLogger = loggerFactory.CreateLogger("Microsoft.Hosting.Lifetime"); DiagnosticListener = diagnosticListener; ActivitySource = activitySource; Propagator = propagator; HttpContextFactory = httpContextFactory; ApplicationBuilderFactory = applicationBuilderFactory; StartupFilters = startupFilters; Configuration = configuration; HostingEnvironment = hostingEnvironment; }
/// <summary> /// 获取指定URL的功能信息 /// </summary> public static IFunction GetFunction(this ControllerBase controller, string url) { url = url.StartsWith("https://") || url.StartsWith("http://") ? new Uri(url).AbsolutePath : !url.StartsWith("/") ? $"/{url}" : url; IServiceProvider provider = controller.HttpContext.RequestServices; IHttpContextFactory factory = provider.GetService <IHttpContextFactory>(); HttpContext httpContext = factory.Create(controller.HttpContext.Features); httpContext.Request.Path = url; httpContext.Request.Method = "POST"; RouteContext routeContext = new RouteContext(httpContext); IRouteCollection router = controller.RouteData.Routers.OfType <IRouteCollection>().FirstOrDefault(); if (router == null) { return(null); } router.RouteAsync(routeContext).Wait(); if (routeContext.Handler == null) { return(null); } RouteValueDictionary dict = routeContext.RouteData.Values; string areaName = dict.GetOrDefault("area")?.ToString(); string controllerName = dict.GetOrDefault("controller")?.ToString(); string actionName = dict.GetOrDefault("action")?.ToString(); IFunctionHandler handler = provider.GetService <IFunctionHandler>(); return(handler?.GetFunction(areaName, controllerName, actionName)); }
public HostingApplicationWrap( RequestDelegate application, ILogger logger, DiagnosticListener diagnosticSource, IHttpContextFactory httpContextFactory) : base(application, logger, diagnosticSource, httpContextFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="HttpListenerBase"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTPS port is 443</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <param name="certificate">Certificate to use</param> /// <param name="protocol">which HTTPS protocol to use, default is TLS.</param> /// <param name="requireClientCerts">True to require SSL client certificates</param> protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, SslProtocols protocol, bool requireClientCerts) : this(address, port, factory) { _certificate = certificate; _requireClientCerts = requireClientCerts; _sslProtocol = protocol; }
// This is called at application startup, but note that it // does nothing except get our service(s) ready for runtime. // It does not actually use the service. public MembershipService(IHttpContextFactory httpContextFactory) { if (httpContextFactory == null) { throw new ArgumentNullException("httpContextFactory"); } this.httpContextFactory = httpContextFactory; }
public CurrentUser(IHttpContextFactory httpContextFactory) { // Using a guard clause ensures that if the DI container fails // to provide the dependency you will get an exception if (httpContextFactory == null) { throw new ArgumentNullException("httpContextFactory"); } this.httpContextFactory = httpContextFactory; }
public RPCMiddleware(RequestDelegate next, IRPCAuthorization authorization, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory) { Guard.NotNull(next, nameof(next)); Guard.NotNull(authorization, nameof(authorization)); this.next = next; this.authorization = authorization; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.httpContextFactory = httpContextFactory; }
public HostingApplication( RequestDelegate application, ILogger logger, DiagnosticListener diagnosticSource, IHttpContextFactory httpContextFactory) { _application = application; _diagnostics = new HostingApplicationDiagnostics(logger, diagnosticSource); _httpContextFactory = httpContextFactory; }
public HostingApplication( RequestDelegate application, ILogger logger, DiagnosticSource diagnosticSource, IHttpContextFactory httpContextFactory) { _application = application; _logger = logger; _diagnosticSource = diagnosticSource; _httpContextFactory = httpContextFactory; }
public HostingEngine( IServerManager serverManager, IStartupManager startupManager, IApplicationBuilderFactory builderFactory, IHttpContextFactory httpContextFactory) { _serverManager = serverManager; _startupManager = startupManager; _builderFactory = builderFactory; _httpContextFactory = httpContextFactory; }
/// <summary> /// Listen for regular HTTP connections /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTP port is 80.</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <exception cref="ArgumentNullException"><c>address</c> is null.</exception> /// <exception cref="ArgumentException">Port must be a positive number.</exception> protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory) { Check.Require(address, "address"); Check.Min(1, port, "port"); Check.Require(factory, "factory"); _address = address; _port = port; _factory = factory; _factory.RequestReceived += OnRequestReceived; }
public RPCMiddleware(RequestDelegate next, IRPCAuthorization authorization, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory, DataFolder dataFolder) { Guard.NotNull(next, nameof(next)); Guard.NotNull(authorization, nameof(authorization)); this.next = next; this.authorization = authorization; this.logger = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode"); this.httpContextFactory = httpContextFactory; this.dataFolder = dataFolder; }
/// <summary> /// Listen for regular HTTP connections /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTP port is 80.</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <exception cref="ArgumentNullException"><c>address</c> is null.</exception> /// <exception cref="ArgumentException">Port must be a positive number.</exception> protected HttpListenerBase(IPAddress address, int port, IHttpContextFactory factory) { Check.Require(address, "address"); Check.Min(0, port, "port"); Check.Require(factory, "factory"); _address = address; _port = port; _factory = factory; _factory.RequestReceived += OnRequestReceived; }
public SystemErrorHandler( IHttpContextFactory httpContextFactory, ISystemController systemController ) { if (httpContextFactory == null) throw new ArgumentNullException("httpContextFactory"); if (systemController == null) throw new ArgumentNullException("systemController"); this.httpContextFactory = httpContextFactory; this.systemController = systemController; }
public SystemErrorHandler( IHttpContextFactory httpContextFactory, ISystemController systemController ) { if (httpContextFactory == null) { throw new ArgumentNullException("httpContextFactory"); } if (systemController == null) { throw new ArgumentNullException("systemController"); } this.httpContextFactory = httpContextFactory; this.systemController = systemController; }
public TenantInitializer( IContextUtilities contextUtilities, IHttpContextFactory httpContextFactory, IApplicationContext appContext ) { if (contextUtilities == null) throw new ArgumentNullException("contextUtilities"); if (httpContextFactory == null) throw new ArgumentNullException("httpContextFactory"); if (appContext == null) throw new ArgumentNullException("appContext"); // Lookup the current tenant and put it into ambient context on the current request var context = httpContextFactory.GetHttpContext(); appContext.CurrentTenant = contextUtilities.GetTenantFromContext(context); }
public StdioServer(TextReader input, ISharedTextWriter writer) { _input = input; _writer = writer; _cancellation = new CancellationTokenSource(); _httpContextAccessor = new HttpContextAccessor(); _httpContextFactory = new HttpContextFactory(_httpContextAccessor); var features = new FeatureCollection(); var requestFeature = new RequestFeature(); var responseFeature = new ResponseFeature(); features.Set <IHttpRequestFeature>(requestFeature); features.Set <IHttpResponseFeature>(responseFeature); Features = features; }
public HostingApplication( RequestDelegate application, ILogger logger, DiagnosticListener diagnosticSource, IHttpContextFactory httpContextFactory) { _application = application; _diagnostics = new HostingApplicationDiagnostics(logger, diagnosticSource); if (httpContextFactory is DefaultHttpContextFactory factory) { _defaultHttpContextFactory = factory; } else { _httpContextFactory = httpContextFactory; } }
public RPCMiddleware( RequestDelegate next, IRPCAuthorization authorization, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory, DataFolder dataFolder, string contentType = "application/json; charset=utf-8") { Guard.NotNull(next, nameof(next)); Guard.NotNull(authorization, nameof(authorization)); this.next = next; this.authorization = authorization; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.httpContextFactory = httpContextFactory; this.dataFolder = dataFolder; this.ContentType = contentType; }
public RPCMiddleware( RequestDelegate next, IRPCAuthorization authorization, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory, DataFolder dataFolder, RpcSettings rpcSettings) { Guard.NotNull(next, nameof(next)); Guard.NotNull(authorization, nameof(authorization)); this.next = next; this.authorization = authorization; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.httpContextFactory = httpContextFactory; this.dataFolder = dataFolder; this.contentType = rpcSettings.RPCContentType; }
public HostingApplication( RequestDelegate application, ILogger logger, DiagnosticListener diagnosticSource, ActivitySource activitySource, DistributedContextPropagator propagator, IHttpContextFactory httpContextFactory) { _application = application; _diagnostics = new HostingApplicationDiagnostics(logger, diagnosticSource, activitySource, propagator); if (httpContextFactory is DefaultHttpContextFactory factory) { _defaultHttpContextFactory = factory; } else { _httpContextFactory = httpContextFactory; } }
public StdioServer(TextReader input, ISharedTextWriter writer) { _input = input; _writer = writer; _cancellation = new CancellationTokenSource(); _httpContextAccessor = new HttpContextAccessor(); _objectPoolProvider = new DefaultObjectPoolProvider(); _formOptions = Microsoft.Extensions.Options.Options.Create(new FormOptions()); _httpContextFactory = new HttpContextFactory(_objectPoolProvider, _formOptions, _httpContextAccessor); var features = new FeatureCollection(); var requestFeature = new RequestFeature(); var responseFeature = new ResponseFeature(); features.Set <IHttpRequestFeature>(requestFeature); features.Set <IHttpResponseFeature>(responseFeature); Features = features; }
public GenericWebHostService(IOptions <GenericWebHostServiceOptions> options, IServer server, ILogger <GenericWebHostService> logger, DiagnosticListener diagnosticListener, IHttpContextFactory httpContextFactory, IApplicationBuilderFactory applicationBuilderFactory, IEnumerable <IStartupFilter> startupFilters, IConfiguration configuration, IHostingEnvironment hostingEnvironment) { Options = options.Value; Server = server; Logger = logger; DiagnosticListener = diagnosticListener; HttpContextFactory = httpContextFactory; ApplicationBuilderFactory = applicationBuilderFactory; StartupFilters = startupFilters; Configuration = configuration; HostingEnvironment = hostingEnvironment; }
public LocaleInitializer( IContextUtilities contextUtilities, IHttpContextFactory httpContextFactory, IApplicationContext appContext ) { if (contextUtilities == null) throw new ArgumentNullException("contextUtilities"); if (httpContextFactory == null) throw new ArgumentNullException("httpContextFactory"); if (appContext == null) throw new ArgumentNullException("appContext"); this.contextUtilities = contextUtilities; this.httpContextFactory = httpContextFactory; this.appContext = appContext; // Execute on creation GetLocaleFromContext(); }
private static HostingApplication CreateApplication(IHttpContextFactory httpContextFactory = null, bool useHttpContextAccessor = false) { var services = new ServiceCollection(); services.AddOptions(); if (useHttpContextAccessor) { services.AddHttpContextAccessor(); } httpContextFactory ??= new DefaultHttpContextFactory(services.BuildServiceProvider()); var hostingApplication = new HostingApplication( ctx => Task.CompletedTask, NullLogger.Instance, new DiagnosticListener("Microsoft.AspNetCore"), httpContextFactory); return(hostingApplication); }
public TenantInitializer( IContextUtilities contextUtilities, IHttpContextFactory httpContextFactory, IApplicationContext appContext ) { if (contextUtilities == null) { throw new ArgumentNullException("contextUtilities"); } if (httpContextFactory == null) { throw new ArgumentNullException("httpContextFactory"); } if (appContext == null) { throw new ArgumentNullException("appContext"); } // Lookup the current tenant and put it into ambient context on the current request var context = httpContextFactory.GetHttpContext(); appContext.CurrentTenant = contextUtilities.GetTenantFromContext(context); }
public WebFileSystem(IFileSystem fileSystem, IHttpContextFactory httpContextFactory) { this.internalFileSystem = fileSystem; this.httpContextFactory = httpContextFactory; }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="port">The port.</param> /// <param name="factory">The factory.</param> /// <param name="certificate">The certificate.</param> /// <param name="clientCertCallback">Callback to validate SSL client certificates.</param> /// <param name="protocol">The protocol.</param> /// <param name="requireClientCerts">True if client SSL certificates are required, otherwise false.</param> public HttpListener(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, RemoteCertificateValidationCallback clientCertCallback, SslProtocols protocol, bool requireClientCerts) : base(address, port, factory, certificate, protocol, requireClientCerts) { }
public FilePathResolver(IHttpContextFactory httpContextFactory) { _httpContextFactory = httpContextFactory; }
public ServerFactory(IApplicationLifetime appLifetime, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory) { _appLifetime = appLifetime; _loggerFactory = loggerFactory; _httpContextFactory = httpContextFactory; }
public Cookie(IHttpContextFactory contextFactory) { _contextFactory = contextFactory; }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="port">The port.</param> /// <param name="factory">The factory.</param> /// <param name="certificate">The certificate.</param> /// <param name="protocol">The protocol.</param> public HttpListener(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, SslProtocols protocol) : base(address, port, factory, certificate, protocol) { }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="port">The port.</param> /// <param name="factory">The factory.</param> /// <param name="certificate">The certificate.</param> public HttpListener(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate) : base(address, port, factory, certificate) { }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTP port is 80.</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <exception cref="ArgumentNullException"><c>address</c> is null.</exception> /// <exception cref="ArgumentException">Port must be a positive number.</exception> public HttpListener(IPAddress address, int port, IHttpContextFactory factory) : base(address, port, factory) { }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">The address.</param> /// <param name="port">The port.</param> /// <param name="factory">The factory.</param> /// <param name="certificate">The certificate.</param> /// <param name="protocol">The protocol.</param> /// <param name="requireClientCerts">True if client SSL certificates are required, otherwise false</param> private HttpListener(IPAddress address, int port, IHttpContextFactory factory, X509Certificate certificate, SslProtocols protocol, bool requireClientCerts) : base(address, port, factory, certificate, protocol, requireClientCerts) { Init(); }
/// <summary> /// Initializes a new instance of the <see cref="HttpListener"/> class. /// </summary> /// <param name="address">IP Address to accept connections on</param> /// <param name="port">TCP Port to listen on, default HTTP port is 80.</param> /// <param name="factory">Factory used to create <see cref="IHttpClientContext"/>es.</param> /// <exception cref="ArgumentNullException"><c>address</c> is null.</exception> /// <exception cref="ArgumentException">Port must be a positive number.</exception> private HttpListener(IPAddress address, int port, IHttpContextFactory factory) : base(address, port, factory) { Init(); }