Commit Graph

34 Commits

Author SHA1 Message Date
Stephen Halter f91ae20a3c
Improve RequestAborted token handling (#2977)
- Improve test reliability of tests verifying the RequestAborted token gets tripped
- Once the response body is completed, don't fire the token for that request even if it is accessed later on.
2018-10-04 16:48:50 -07:00
Stephen Halter f3b6430aab
Initialize Heartbeat in KestrelServer.StartAsync (#2939)
Fixes #2850 again
2018-09-17 16:43:30 -07:00
Stephen Halter f70ba53253
Fix race when SystemClock is accessed before first heartbeat (#2851) 2018-08-27 10:59:29 -07:00
David Fowler 68a0863524
General connection management (#2834)
This change makes the handling of graceful shutdown work for more than just http scenarios. This should allow us to move TLS further out and should also allow us to start moving things to connection middleware instead of connection adapters.
Summary of the things changed/added:
- Added IConnectionLifetimeNotificationFeature that represents an attempt to gracefully close the connection that isn't being aborted. This feels pretty awful but we may have to do it.
- Moved connection management to the ConnectionDispatcher and out of the HttpConnectionMiddleware
- Removed Http from the names of the ConnectionManager and Heartbeat
2018-08-22 20:35:28 -07:00
Stephen Halter 0e99235d59
Add in-memory functional test project (#2780)
- Run AddressRegistrationTests independently to avoid port conflicts
- Only run tests that verify transport behavior for each transport
2018-08-07 15:34:11 -07:00
John Luo 8a74cf3ed5 Gracefully shutdown HTTP/2 connections on server and client initiated shutdown 2018-08-07 10:59:29 -07:00
Pavel Krymets 2f2a0047a1
React to pool cleanup (#2526) 2018-04-30 08:37:15 -07:00
David Fowler e7d3b0c5f9
Remove KestrelThreadPool abstraction and replaced it with PipeScheduler (#2371) 2018-03-12 14:49:19 -07:00
Mike Harder 4afaa386db
Remove unnecessary usings (#2326) 2018-02-16 14:04:16 -08:00
David Fowler b8a1c04ffb
Make the HttpParser a singleton (#2203)
- It's completely stateless so make it a singleton
- Fixed tests
2017-12-03 13:27:36 -08:00
Cesar Blum Silveira a31d1e024c Merge code paths duplicated between HTTP/1.x and HTTP/2 implementations (#2017).
- Most of the shared code is in the HttpProtocol class (former Frame)
- Virtual calls handle protocol-specific things
- Move the ProcessRequestsAsync loop to HttpProtocol
- Implement HTTP/1.x request processing in Http1Connection and HTTP/2
  in Http2Stream, with Http1Connection<T> and Http2Stream<T> subclassing
  those classes in order to handle the generic HttpContext parameter
- Split MessageBody into Http1MessageBody and Http2MessageBody,
  with MessageBody containing shared member variables and methods
2017-09-14 17:35:57 -07:00
Stephen Halter 284367db9f Improve ConnectionLimitMiddleware and connection pipeline building (#2010)
* Improve ConnectionLimitMiddleware and connection pipeline building
* Add IDecrementConcurrentConnectionCountFeature
* Flow connection features from connection middleware
2017-08-30 11:30:20 -07:00
David Fowler 7ebbdad974 Add support for connection scopes if logging is enabled (#1953)
* Add support for connection scopes if logging is enabled
- Don't create a scope if logging isn't on
- Copied the pattern we use in Hosting
2017-07-12 11:45:08 -07:00
Cesar Blum Silveira eca4bfe6c3 Add response minimum data rate feature. 2017-07-07 22:37:25 -07:00
Cesar Blum Silveira fcc04f8c3d Add request body minimum data rate feature (#1874). 2017-06-08 14:36:03 -07:00
Pavel Krymets 3c731ceb13 React to logging in DI changes (#1873) 2017-06-02 08:34:22 -07:00
Nate McMaster c343628926 Implement max connection limits
- Added new options to allow configuring the maximum number of concurrent connections and upgraded connections.
- `KestrelServerLimits.MaxConcurrentConnections` defaults unlimited.
- `KestrelServerLimits.MaxConcurrentUpgradedConnections` defaults to unlimited.
- Calls to IHttpUpgradeFeature.UpgradeAsync() will throw when the MaxConcurrentUpgradedConnections limit has been reached.
- Kestrel will close new connections without response when MaxConcurrentConnections is reached.
2017-05-26 12:27:48 -07:00
Stephen Halter 6c0af445e5 Fix flaky test and improve TestServer (#1859) 2017-05-24 15:45:54 -07:00
David Fowler b21f84543a Use WebHostBuilder as an implementation detail of TestServer (#1804)
- This will make tests run more similarly so we can swap out the
transport more easily.
2017-05-03 19:35:09 -07:00
David Fowler 0755495ce5 Remove Logging dependency from the http parser (#1780)
* Remove Logging dependency from the http parser
2017-04-27 08:46:08 -07:00
Stephen Halter a053ca4758 Move shutdown logic from transport to core (#1707)
* Move shutdown logic from transport to core
* Use weak references to track FrameConnections
2017-04-19 18:08:36 -07:00
Stephen Halter 11ab602b2f Make timeout logic transport agnostic (#1649)
* Make timeout logic transport agnostic

* PR feedback

* More PR feedback
2017-04-12 16:15:46 -07:00
Ben Adams d29e4d4cf0 Specialized struct generics rather than interface (#1640)
Changed the IHttpParser interface to be generic. This lets use a struct to 
get better code generation and also should allow us to inline calls back into
the handler from the parser.
2017-04-10 19:30:18 -07:00
David Fowler 239b691ff5 A few HttpParser changes (#1624)
- Renamed KestrelHttpParser to HttpParser
- Removed the generic virtual dispatch as it turns out to be an
order of magnitude slower than regular virtual dispatch. This change
means we also lose the inlining of Frame.OnStartLine and Frame.OnHeader.
2017-04-07 08:35:53 -07:00
Cesar Blum Silveira f253dbc0c0 Split transport-specific tests and general tests into distinct test projects (#1588).
* Rename EngineTests to LibuvTransportTests.
* Move libuv-specific tests into their own test project.
* Move LibuvOutputConsumerTests.AllocCommitCanBeCalledAfterConnectionClose to new OutputProducerTests class and rename it to WritesNoopAfterConnectionCloses.
* Remove TransportContext from TestServiceContext.
* Make KestrelTests depend on Kestrel.Core only.
* Rename Microsoft.AspNetCore.Server.Kestrel.KestrelTests to Microsoft.AspNetCore.Server.Kestrel.Core.Tests.
* Add Microsoft.AspNetCore.Server.Kestrel.Tests test project for WebHostBuilderKestrelExtensionsTests.
* Increase socket receive timeout in MaxRequestBufferSizeTests to mitigate flakiness.
* Anything using TestServer should be a functional test.
* Move out of LibuvTransportTests tests that are not specific to LibuvTransport.
  - Move to RequestTests:
    - Http11 (rename to Http11KeptAliveByDefault)
    - Http10ContentLength (rename to Http10NotKeptAliveByDefault)
    - Http10KeepAlive
    - Http10KeepAliveNotUsedIfResponseContentLengthNotSet (rename to Http10KeepAliveNotHonoredIfResponseContentLengthNotSet)
    - Http10ContentLengthKeepAlive (rename to Http10KeepAliveHonoredIfResponseContentLengthSet)
    - Expect100ContinueForBody (rename to Expect100ContinueHonored)
    - ZeroContentLengthAssumedOnNonKeepAliveRequestsWithoutContentLengthOrTransferEncodingHeader
    - ConnectionClosesWhenFinReceivedBeforeRequestCompletes (test was actually not marked as Theory, and was incorrect)
    - RequestsCanBeAbortedMidRead
    - RequestHeadersAreResetOnEachRequest
    - UpgradeRequestIsNotKeptAliveOrChunked
    - HeadersAndStreamsAreReused (rename to HeadersAndStreamsAreReusedAcrossRequests)
  - Move to ResponseTests:
    - Http10RequestReceivesHttp11Response (rename to Http11ResponseSentToHttp10Request)
    - ZeroContentLengthSetAutomaticallyAfterNoWrites
    - ZeroContentLengthSetAutomaticallyForNonKeepAliveRequests
    - ZeroContentLengthNotSetAutomaticallyForHeadRequests
    - ZeroContentLengthNotSetAutomaticallyForCertainStatusCodes
    - ConnectionClosedAfter101Response
    - ThrowingResultsIn500Response
    - ThrowingAfterWritingKillsConnection
    - ThrowingAfterPartialWriteKillsConnection
    - ThrowingInOnStartingResultsInFailedWritesAnd500Response
    - ThrowingInOnCompletedIsLoggedAndClosesConnection
    - FailedWritesResultInAbortedRequest
    - NoErrorsLoggedWhenServerEndsConnectionBeforeClient
    - NoResponseSentWhenConnectionIsClosedByServerBeforeClientFinishesSendingRequest
    - ResponseHeadersAreResetOnEachRequest
    - OnStartingCallbacksAreCalledInLastInFirstOutOrder
    - OnCompletedCallbacksAreCalledInLastInFirstOutOrder
  - Remove:
    - RePathEscapeTests (theory data to HttpParsingData)
    - ReDisconnectingClient (what was that testing?)
2017-04-06 19:09:40 -07:00
Cesar Blum Silveira 7ceea5323a Rename namespaces/directories/classes in Kestrel.Core and Transport.Libuv (#1582).
- Put everything in the libuv transport package under `Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.*` namespaces.
- Move stuff in Transport.Libuv/Internal/Http and Transport.Libuv/Internal/Infrastructure to Transport.Libuv/Internal (keep the Networking directory for the libuv wrappers).
- Add `Libuv` prefix to most libuv internal classes.
- Rename `KestrelEngine` to `LibuvTransport`.
- Rename `SocketOutputConsumer` to `LibuvOutputConsumer`.
- Rename `SocketOutputProducer` to `OutputProducer`.
- Fix namespaces in `Microsoft.AspNetCore.Server.Kestrel.Core.`
2017-04-04 13:45:02 -07:00
Cesar Blum Silveira 6a66323a99 Remove Kestrel.Core dependency from Transport.Libuv (#1584). 2017-04-03 20:54:01 -07:00
Cesar Blum Silveira 6bd0344880 Add Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions project (#1582).
- Changes the design to have one ConnectionHandler per endpoint.
2017-04-03 15:09:03 -07:00
Stephen Halter 7f785588ef Transport agnostic kestrel refactoring (#1551)
- Add transport interfaces
- Create separate Core and Libuv projects

#828
2017-03-29 16:06:05 -07:00
David Fowler cb6059c143 Make the IHttpParser per frame and add a reset (#1415)
* Make the IHttpParser per frame and add a reset
- Made the IHttpParser a per frame object so state can be stored
across method calls and parses.
- Added HttpParserFactory to ServiceContext
2017-03-01 13:12:03 -08:00
Pavel Krymets d3694f085a Add IHttpParser interface (#1414) 2017-03-01 11:55:36 -08:00
Stephen Halter fde0f6b2fc Add an option to Kestrel to disable threadpool dispatching 2017-02-28 10:14:58 -08:00
Stephen Halter 2351c1b558 Create a direct way to configure Kestrel endpoints
- Replace endpoint configuration via .UseUrls() or --server.urls with Listen*
  methods on KestrelSerrverOptions.
- Replace IConnectionFilter with IConnectionAdapter which no longer exposes
  ServerAddress via a context.
- Simplify libuv Listener classes
- Support systemd socket activation
- Add docker-based test for systemd socket activation to be run on Travis
2017-01-06 17:37:58 -08:00
Cesar Blum Silveira 19f8958fa8 Move TestServer to shared directory. 2016-09-06 12:47:24 -07:00