Commit Graph

50 Commits

Author SHA1 Message Date
Nate McMaster c2f15fcac3 Move user-facing strings into resource files 2017-04-26 17:22:55 -07:00
David Fowler 566a587126 Added ApplicationSchedulingMode to KestrelServerOptions (#1759)
* Added ApplicationSchedulingMode to KestrelServerOptions
- Made default mode Default instead of ThreadPool
2017-04-25 00:37:09 -07:00
David Fowler 9e80fb65bd Removed the wrote after disconnect log (#1747)
- It's not very useful
2017-04-24 17:34:56 -07:00
Nate McMaster 39047638cc Add debug logging in address binding when IPv6Any fails 2017-04-24 17:14:43 -07:00
David Fowler a98581670e Schedule connection adapter reads on configured thread pool (#1741)
* Schedule connection adapter reads on configured thread pool
- This should speed up connection adapters as we don't block
new reads. It *might* also help some of the test flakiness
2017-04-24 12:19:22 -07:00
Pavel Krymets df9e48b1f0 Add cancellation support for write async (#1736) 2017-04-24 11:58:08 -07:00
Nate McMaster ee9feedc27 Improve implementation of IHttpUpgradeFeature
After upgrade has been accepted by the server:
 - Reads to HttpRequest.Body always return 0
 - Writes to HttpResponse.Body always throw
 - The only valid way to communicate is to use the stream returned by IHttpUpgradeFeature.UpgradeAsync()

Also, Kestrel returns HTTP 400 if requests attempt to send a request body along with Connection: Upgrade
2017-04-20 12:42:58 -07:00
David Fowler d1494224f4 Make the tests that use the Heartbeat more deterministic. (#1724)
- Added Start to Heartbeat and made OnHeartbeat internal
- Explicitly call start in tests
2017-04-20 01:41:37 -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
Nate McMaster 7a3a731686 Refactor address binding and handle EAFNOSUPPORT
- Simplify KestrelServer by refactoring address binding into a separate class
 - Use strategy pattern to implement address binding for different sceanrios
 - Add fallback from binding 0.0.0.0 if binding to [::] fails (can happen if UvException with EAFNOSUPPORT is thrown)
2017-04-19 15:58:12 -07:00
David Fowler e4af3f7e35 Expose a UseTransportThread property on KestrelServerOptions (#1695)
- This property will force Kestrel to use whatever scheduler the transport
used when write and read callbacks are fired. The default value is false so
all calls to user code including connection adapters, and the application function,
and cancellation token callbacks.
- Transports may expose configuration that changes what the transport thread is.
- Removed InternalKestrelServerOptions.cs
- Added a configurable UseSockets overload (even though there are no options yet)
- Remove RequiresDispatch from the IConnectionInformation
2017-04-17 12:58:28 -07:00
David Fowler 85d883456b Remove Reset from IHttpParser (#1700)
* Remove Reset from IHttpParser
- The parser isn't stateful and doesn't need it
2017-04-17 00:37:40 -07:00
David Fowler 31cc1e5018 Fix extra space 2017-04-16 09:25:28 -07:00
David Fowler 6a403d231e Clean up IThreadPool interface (#1696)
- Remove tcs completion methods
2017-04-15 19:04:44 -07:00
Stephen Halter 8cd58b042c Fix tests using Heartbeat 2017-04-14 16:26:27 -07:00
Stephen Halter 7aa7b3e0a9 Track connections until request processing completes
- Paves the way to allow request processing to continue during server shutdown
  even after a client disconnects.
2017-04-14 16:26:27 -07:00
Nate McMaster c08c57f764 Reject HTTP/1.1 requests that do not have a correct Host header
Improves Kestrel to reject requests that don't conform to HTTP spec.

RFC 7230 section 5.4: "A server MUST respond with a 400 (Bad Request)
status code to any HTTP/1.1 request message that lacks a Host header
 field and to any request message that contains more than one Host
 header field or a Host header field with an invalid field-value."

See https://tools.ietf.org/html/rfc7230#section-5.4.

Other changes:

 - update VS code settings to work better with CLI 2.0
 - update tests that were subject to infinite hangs
2017-04-14 15:48:21 -07:00
Geoff Kizer efa0a48fb1 Add initial Socket transport for Kestrel (#1659)
- This change adds the initial socket transport for Kestrel, all of the tests pass but there are still
a couple of things that aren't done yet.
- The functional tests support running both on both transports but tests aren't running for sockets right now. We need to parameterize these. 
- TimeoutServerTests hard code the libuv transport, this needs to support any transport.
- There is no handling of connection stopping on application shutdown. This is being implemented in kestrel core so transports don't need to handle it. Sockets won't be the default transport until that is the case.
- Performance needs to be looked at, today the SocketTransport doesn't dispatch by default and we're not buffering in kestrel.core, this can hurt as the number of kernel calls map 1:1 with application writes.
2017-04-13 23:10:06 -07:00
John Luo 0723d46ec4 Honor PreferHostingUrls #1575 2017-04-13 18:12:53 -07:00
Pavel Krymets 3045cff3c5 Fix adapted output pipe options (#1682) 2017-04-13 15:54:48 -07:00
Stephen Halter 6036f27f52 Fix deadlocks in startup and shutdown 2017-04-13 12:47:34 -07:00
Nate McMaster ed4a27a827 Remove ListenOptions.Scheme and move IConnectionFilter to .Internal namespace
Add an internal API to ListenOptions to determine if an endpoint is configured to use HTTPS. This is a temporary as the design of connection adapters and configuration will churn before release.
2017-04-13 09:45:26 -07:00
David Fowler 8258d300e2 Small tweaks to timer logic (#1668)
- Avoid null refs in tests by ignoring null IKestrelTrace
- Use a static callback for the timer callback

Fixes #1667
2017-04-13 09:29:43 -07:00
Chris R 8b6d933711 Add ConfigureAwaits to prevent test deadlocks 2017-04-13 07:26:51 -07:00
Chris R e043fa871e Make IServer Start and Stop async 2017-04-12 22:23:05 -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
Ben Adams 2863cca8ca FrameFeatureCollection benchmark (#1643) 2017-04-09 16:02:18 -07:00
Ben Adams fb22629da6 Use Span.IndexOf rather than Contains (#1638)
- Remove Contains method and use IndexOf (which is already vectorized) to look for CR in header values.
2017-04-08 23:45:26 -07:00
Pavel Krymets 53b0eea2ec Use writable buffer writer (#1564) 2017-04-07 14:40:10 -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
Pranav K 3b016e6832 Use 4.3.0 version of System.Threading.Tasks.Extensions 2017-04-05 18:03:24 -07:00
Pavel Krymets dd02ba577f Use corefxlab and corefx by source (#1612) 2017-04-05 15:37:45 -07:00
Stephen Halter b40d8b4248 Fix naming of IConnectionInformation.OutputReaderScheduler (#1608) 2017-04-04 21:30:33 -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
Pavel Krymets c7113e1c60 Revert "Fetch corefx lab sources and compile them into kestrel (#1581)"
This reverts commit 13ee32b7ab.
2017-04-03 14:08:27 -07:00
Pavel Krymets 13ee32b7ab Fetch corefx lab sources and compile them into kestrel (#1581) 2017-04-03 13:21:17 -07:00
David Fowler f787c5277c Remove unused span (#1599) 2017-04-02 23:53:49 -07:00
David Fowler 547ad80a27 Don't update consumed if we didn't see a new line (#1592)
* Don't update consumed if we didn't see a new line
- The start line parser incorrectly updated the consumed cursor
when it attempted to find new lines across buffers. This change fixes
that and also removes passing the span by reference (which will be illegal).
- Added a unit test
2017-04-02 00:03:06 -07:00
Nate McMaster 83958886cc
Implement IHttpRequestIdentifierFeature on Frame
This feature generates a unique ID per request. This unique ID can be
used in event source and logging.

Also, this change improves KestrelEventSource by moving it back into the
Kestrel.Core assembly and de-coupling from the Libuv transport. This
adds two new events, RequestStart and RequestStop, which can be used to
identify the correlation between connection ID and request trace
identifier.
2017-03-31 16:54:35 -07:00
Cesar Blum Silveira 6b9d54265f Call ProduceEnd() before consuming request body if response has already started (#1530). 2017-03-31 11:08:55 -07:00
David Fowler b0bd5475cd More decoupling (#1572)
- Remove Libuv and Hosting dependency from Kestrel.Core
- Kestrel.Https and Kestrel.Core depend on Hosting.Abstractions

* wip

* Added separate ServerAddressesFeature

* Review feedback
- Added TlsConnectionFeature to Https
2017-03-30 20:14:50 -07:00
Cesar Blum Silveira 1be31ae2ce Throw if UseUrls specifies HTTPS or path base (#1519). 2017-03-29 20:23:51 -07:00
Cesar Blum Silveira e64bffd25c Remove deprecated property KestrelServerOptions.MaxRequestBufferSize (#1027). 2017-03-29 20:15:08 -07:00
Nate McMaster 6b6a8347cc
Add Connection as a primary request header 2017-03-29 16:40:50 -07:00
Nate McMaster 686829d226
Add tests for WritableBuffer extensions and rename WriteAscii => WriteAsciiNoValidation 2017-03-29 16:10:31 -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