public void MaxRequestLineSizeValid(int value) { var o = new KestrelServerLimits(); o.MaxRequestLineSize = value; Assert.Equal(value, o.MaxRequestLineSize); }
public async Task SETTINGS_MaxFieldSectionSizeSent_ServerReceivesValue() { await Http3Api.InitializeConnectionAsync(_echoApplication); var inboundControlStream = await Http3Api.GetInboundControlStream(); var incomingSettings = await inboundControlStream.ExpectSettingsAsync(); var defaultLimits = new KestrelServerLimits(); Assert.Collection(incomingSettings, kvp => { Assert.Equal((long)Http3SettingType.MaxFieldSectionSize, kvp.Key); Assert.Equal(defaultLimits.MaxRequestHeadersTotalSize, kvp.Value); }); var outboundcontrolStream = await Http3Api.CreateControlStream(); await outboundcontrolStream.SendSettingsAsync(new List <Http3PeerSetting> { new Http3PeerSetting(Http3SettingType.MaxFieldSectionSize, 100) }); var maxFieldSetting = await Http3Api.ServerReceivedSettingsReader.ReadAsync().DefaultTimeout(); Assert.Equal(Http3SettingType.MaxFieldSectionSize, maxFieldSetting.Key); Assert.Equal(100, maxFieldSetting.Value); }
public void MaxRequestHeaderCountValid(int value) { var o = new KestrelServerLimits(); o.MaxRequestHeaderCount = value; Assert.Equal(value, o.MaxRequestHeaderCount); }
public void MaxResponseBufferSizeValid(long?value) { var o = new KestrelServerLimits(); o.MaxResponseBufferSize = value; Assert.Equal(value, o.MaxResponseBufferSize); }
/// <summary> /// Configure Kestrel server limits from appsettings.json is not supported so we manually copy from config. /// https://github.com/aspnet/KestrelHttpServer/issues/2216 /// </summary> private static void ConfigureKestrelServerLimits(WebHostBuilderContext builderContext, KestrelServerOptions options) { KestrelServerOptions source = new KestrelServerOptions(); builderContext.Configuration.GetSection(nameof(ApplicationOptions.Kestrel)).Bind(source); KestrelServerLimits limits = options.Limits; KestrelServerLimits sourceLimits = source.Limits; Http2Limits http2 = limits.Http2; Http2Limits sourceHttp2 = sourceLimits.Http2; http2.HeaderTableSize = sourceHttp2.HeaderTableSize; http2.InitialConnectionWindowSize = sourceHttp2.InitialConnectionWindowSize; http2.InitialStreamWindowSize = sourceHttp2.InitialStreamWindowSize; http2.MaxFrameSize = sourceHttp2.MaxFrameSize; http2.MaxRequestHeaderFieldSize = sourceHttp2.MaxRequestHeaderFieldSize; http2.MaxStreamsPerConnection = sourceHttp2.MaxStreamsPerConnection; limits.KeepAliveTimeout = sourceLimits.KeepAliveTimeout; limits.MaxConcurrentConnections = sourceLimits.MaxConcurrentConnections; limits.MaxConcurrentUpgradedConnections = sourceLimits.MaxConcurrentUpgradedConnections; limits.MaxRequestBodySize = sourceLimits.MaxRequestBodySize; limits.MaxRequestBufferSize = sourceLimits.MaxRequestBufferSize; limits.MaxRequestHeaderCount = sourceLimits.MaxRequestHeaderCount; limits.MaxRequestHeadersTotalSize = sourceLimits.MaxRequestHeadersTotalSize; //https://github.com/aspnet/AspNetCore/issues/12614 limits.MaxRequestLineSize = sourceLimits.MaxRequestLineSize - 10; limits.MaxResponseBufferSize = sourceLimits.MaxResponseBufferSize; limits.MinRequestBodyDataRate = sourceLimits.MinRequestBodyDataRate; limits.MinResponseDataRate = sourceLimits.MinResponseDataRate; limits.RequestHeadersTimeout = sourceLimits.RequestHeadersTimeout; }
public void MaxRequestBodySizeValid(long?value) { var limits = new KestrelServerLimits { MaxRequestBodySize = value }; Assert.Equal(value, limits.MaxRequestBodySize); }
public void MaxUpgradedConnectionsValid(long?value) { var limits = new KestrelServerLimits { MaxConcurrentUpgradedConnections = value }; Assert.Equal(value, limits.MaxConcurrentUpgradedConnections); }
public async Task WriteSettings_OneSettingsWrittenWithKestrelDefaults() { var pipe = new Pipe(new PipeOptions(_dirtyMemoryPool, PipeScheduler.Inline, PipeScheduler.Inline)); var frameWriter = CreateFrameWriter(pipe); var kestrelLimits = new KestrelServerLimits(); var settings = new Http3PeerSettings(); settings.HeaderTableSize = (uint)kestrelLimits.Http3.HeaderTableSize; settings.MaxRequestHeaderFieldSectionSize = (uint)kestrelLimits.MaxRequestHeadersTotalSize; await frameWriter.WriteSettingsAsync(settings.GetNonProtocolDefaults()); // variable length ints make it so the results isn't know without knowing the values var payload = await pipe.Reader.ReadForLengthAsync(5); Assert.Equal(new byte[] { 0x04, 0x05, 0x06, 0x80, 0x00 }, payload.ToArray()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHostedService <LifetimeEventsHostedService>(); services.Configure <AuthenticationOptions>(Configuration.GetSection(AuthenticationOptions.Authentication)); // If using IIS: services.Configure <IISServerOptions>(options => { options.AllowSynchronousIO = true; options.MaxRequestBodySize = 30_000_000_000_000; }); services.Configure <FormOptions>(options => { options.MultipartBodyLengthLimit = 3000_000_000; }); services.AddResponseCaching(); services.AddResponseCompression(); services.AddSignalR(); //when call from http://localhost:4200/ as an individual web application! //services.AddCors(options => //{ // options.AddPolicy("CorsPolicy", builder => builder.WithOrigins("http://localhost:4200") // .AllowAnyMethod() // .AllowAnyHeader() // .AllowCredentials()); //}); //services.AddControllers() //only webapi // .ConfigureApiBehaviorOptions(options => // { // options.SuppressConsumesConstraintForFormFileParameters = true; // options.SuppressInferBindingSourcesForParameters = true; // options.SuppressModelStateInvalidFilter = true; // options.SuppressMapClientErrors = true; // options.ClientErrorMapping[404].Link = "https://httpstatuses.com/404"; // }); services.AddControllersWithViews(); // services.AddRouting(); KestrelServerLimits kestrelServerLimits = new KestrelServerLimits(); kestrelServerLimits.MaxRequestBodySize = 330_000_000; services.RegisterCommonServices(Configuration); //esri arcgis server proxy services.AddSingleton <IProxyConfigService, ProxyConfigService>(serviceProvider => new ProxyConfigService(serviceProvider.GetService <IWebHostEnvironment>(), "/Proxy/proxy.config.json")); services.AddSingleton <IProxyService, ProxyService>(); IProxyConfigService agsProxyConfig = services.BuildServiceProvider().GetService <IProxyConfigService>(); // Loop through the config and add Named Clients for use with IHttpClientFactory agsProxyConfig.Config.ServerUrls.ToList().ForEach(serverUrl => { services.AddHttpClient(serverUrl.Url) .ConfigurePrimaryHttpMessageHandler(serviceProvider => new HttpClientHandler { AllowAutoRedirect = false, Credentials = agsProxyConfig.GetCredentials(agsProxyConfig.GetProxyServerUrlConfig((serverUrl.Url))) }); }); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }