Commit Graph

1253 Commits

Author SHA1 Message Date
Cesar Blum Silveira 197eb43d8a Read request body concurrent to app execution. 2017-05-22 12:23:02 -07:00
Nate McMaster 390582dcf1 Target .NET Standard 2.0 (#1849) 2017-05-20 10:37:35 -07:00
Pavel Krymets 34ab089e7b React to scheduler changes (#1846) 2017-05-18 14:49:48 -07:00
Nate McMaster 7f0319f5dd Throw InvalidOperationException from IHttpUpgradeFeature.UpgradeAsync when request is not upgradable 2017-05-17 11:38:42 -07:00
Pavel Krymets d22f689fd2 Add support to use System.Memory as a package instead of internilized source (#1821) 2017-05-16 16:54:03 -07:00
David Fowler cf16d601d6 Remove synchronous Write APIs (#1838) 2017-05-15 19:04:04 -07:00
Stephen Halter 9ab09dbe48 Change Exception to UvException where possible (#1833) 2017-05-15 11:03:04 -07:00
Stephen Halter 41f1922502 Simplify LibuvConnection.OnRead() (#1828)
* Simplify LibuvConnection.OnRead()

- Fix a null reference that sometimes occurs given an EOF status
2017-05-15 11:02:16 -07:00
David Fowler 1a706113d9 Remove rogue ConfigureAwait (#1830)
- We don't do it anywhere else, I assume this is left over
from older legacy
2017-05-12 18:26:52 -07:00
Cesar Blum Silveira cb1d0f3956 Prevent infinite loop in PipelineExtensions.PeekAsyncAwaited() (#1827). 2017-05-12 16:04:38 -07:00
Cesar Blum Silveira 37f15bdd85 Create Frame in FrameConnection. 2017-05-10 16:48:37 -07:00
David Fowler b9518e3684 Invert the dependency between connection adapters and Frame (#1822)
* Invert the dependency between connection adapters and Frame
- Removed PrepareRequest from IAdaptedConnection and instead added
a feature collection to the ConnectionAdapterContext. This allows features to be set
once by the adapter instead of per request. It's the Frame's job to copy features
from the connection level feature collection into the per request feature collection.
- Set the scheme to "https" based on the presence of ITlsConnectionFeature.
- Always set ITlsConnection feature if the HttpsAdaptedConnection doesn't throw during
the handshake
2017-05-10 15:29:43 -07:00
David Fowler c8b6a2be56 More FrameConnection refactoring (#1820)
* More FrameConnection refactoring
- This change reverts the change to complete the writer with an
exception on abort because of the number of first chance exceptions
that get thrown.
- This change also moves connection logging into FrameConnection instead
of being split between the ConnectionHandler and FrameConnection.
- Fixed issues with LibuvOutputConsumerTests that leak WriteReq since
cancelled writes no longer end the connection.
2017-05-09 17:40:25 -07:00
David Fowler c48113ad80 Refactoring and of FrameConnection and Frame (#1816)
* Refactoring and of FrameConnection and Frame
- Building on top of the last refactoring of FrameConnection, this change aims to clean up
the communication between the Frame and FrameConnection by removing some concepts and
being consistent about the communication between Frame and FrameConnection with or without
connection adapters. Changes include:
- Removing ConnectionLifetimeControl, ISocketOutput, StreamSocketOutput
- Moving more initialization of the frame to FrameConnection after the pipes
are setup
- OutputProducer communicates cancellation via the IPipeWriter instead of the output's IPipeReader.
- Frame always communicates via the pipes and that communications flows through the layers to the transport.
This means that each 1/2 of the adapted pipeline handles closing the right side of the transport at the
right time, propagating exceptions as necessary.
- This is how the flow looks now:
            ->                        ->
[transport]     [connection adapters]     [frame]
            <-                        <-
- Transports need to handle a ConnectionAbortedException on the output as a signal to stop
writing and end the connection. This will no longer try to drain the output but will just stop
writing and end the response immediately.
- Remove frame.Abort when cancellation on Write fails.
- Unify the connection shutdown logic
- Dispose 1/2 initialized connection adapters

#1815
2017-05-08 20:44:13 -07:00
Stephen Halter 6e2fdda162 Simplify connection lifetime control flow (#1776)
* Also make IAdaptedConnection disposable
2017-05-05 16:11:01 -07:00
Pavel Krymets 28b479c99a Merge branch 'rel/2.0.0-preview1' into dev 2017-05-05 14:35:41 -07:00
Pavel Krymets a9c165e666 netcoreapp2.0 (#1810) 2017-05-05 14:31:34 -07:00
David Fowler cd1568d7f4 Remove uv_shutdown because FIN is already sent during uv_close (#1811)
* Remove uv_shutdown because FIN is already sent during uv_close

#1808
2017-05-05 12:52:10 -07:00
Stephen Halter 557cf29e4a arespr/knownmethods-optimizations cleanup 2017-05-04 12:27:22 -07:00
Stephen Halter f464760bf8 Merge branch 'arespr/knownmethods-optimizations' into dev 2017-05-04 11:44:54 -07:00
David Fowler 9072e0ba26 Added a ConnectionAbortedException to Transport.Abstractions (#1806)
* Added a ConnectionAbortedException to Transport.Abstractions
- To avoid hard coding TaskCanceledException in each transport
- This PR tries to keep compatibility by converting the ConnectionAbortedException
to a TaskCanceledException on exceptions in FrameRequestStream. The downside is that
this conversion causes an async state machine to be created per call to ReadAsync.
CopyToAsync isn't that bad because it's a single long running task.
2017-05-03 19:38:34 -07:00
David Fowler 35b5d92652 Fix EBUSY errors on uv_loop_close (#1798)
* Fix race where ListenerPrimary is disposed before secondary listeners spin up
- Since we only add listeners to dispatch pipes after receiving the "ack" message
it's possible to have pipes that were created but not acked yet. We might miss
disposal of those pipes if they were never added to the list of _dispatchPipes.

#1761
2017-05-01 14:55:32 -07:00
Nate McMaster 4dc7946cd8 Implement new request trace identifier format
The format:
The trace identifier begins with connection ID and ends with a number that increments with each request per connection.

Example:
Connection ID = xyz
Request 1 = "xyz:00000001"
Request 2 = "xyz:00000002"
...
Request 15 = "xyz:0000000F"
Request 16 = "xyz:00000010"
2017-05-01 09:50:47 -07:00
David Fowler 9a5d6c8879 More shutdown tweaks (#1760)
* More shutdown tweaks
- Added assert if loop has ended before starting the shutdown
sequence.
2017-04-29 01:15:10 -07:00
Stephen Halter 7122b6c4aa Fix flaky heartbeat test (#1794) 2017-04-29 00:42:27 -07:00
David Fowler 749e282102 Prepare for OnReader/WriterCallbacks changes (#1791)
- This change does a few things:

1. It adds the events we will replace with
pipe events to IConnectionContext and IConnectionInformation to get out of
band notifications about pipe completions.

2. It also implements those callbacks
and exposing slight changes we'll need to make once we have them. The idea is
that we can delete/replace these methods once we have the new pipe API and things
will keep working.
2017-04-29 00:41:48 -07:00
David Fowler cfad8051d5 Merge branch 'rel/2.0.0-preview1' into dev 2017-04-27 21:00:46 -07:00
David Fowler 0e372edb2c Removed UseTransportThread (#1781) 2017-04-27 20:59:50 -07:00
David Fowler 5b62024fc8 * Properly handle FINs and resets in the SocketConnection (#1782)
- FIN from the client shouldn't throw
- Forced close from the server should throw
- Properly wrap connection reset exceptions and other exceptions
in IO exceptions
- This gives kestrel control over when the output closes
- Fixed one test that assumed libuv
- Dispose the connection to yield the reader

Fixes #1774
2017-04-27 17:55:35 -07:00
Stephen Halter 79ea2bb9b3 Quick fix for SslStream ODEs in HttpsAdaptedConnection.PrepareRequest (#1786) 2017-04-27 16:56:07 -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
Nate McMaster c2f15fcac3 Move user-facing strings into resource files 2017-04-26 17:22:55 -07:00
Nate McMaster 9464003bda Add wait in ListenerPrimaryTests to avoid race condition with List.Add 2017-04-26 11:03:28 -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
Stephen Halter f26c31c116 Fix scope id test failures on mac and linux (#1754) 2017-04-24 17:15:41 -07:00
Nate McMaster 39047638cc Add debug logging in address binding when IPv6Any fails 2017-04-24 17:14:43 -07:00
Stephen Halter c22f8f5c59 Fix potential race in LibuvThread.StopAsync (#1756) 2017-04-24 16:47:48 -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
David Fowler 7e5604b2f5 Remove async from OnRead (#1746)
- Remove async from fast path.
- Added ApplyBackpressureAsync that pauses and resumes reading
2017-04-24 11:58:52 -07:00
Pavel Krymets df9e48b1f0 Add cancellation support for write async (#1736) 2017-04-24 11:58:08 -07:00
David Fowler 71d2abed06 More clean up of LibuvConnection (#1743)
* More clean up of LibuvConnection
- Use C# 7
- Use Buffer<T>.Pin to get access to the underlying
pointer instead of using TryGetPointer.
2017-04-23 20:45:03 -07:00
David Fowler db44f5b672 Clean up LibuvOutputConsumer (#1744)
* Clean up LibuvOutputConsumer
- Added UvShutdownReq.ShutdownAsync
- Added Debug.Assert in LibuvAwaitable since it should never race.
2017-04-23 20:22:49 -07:00
David Fowler 650a3ccc26 Pass exception to Complete (#1739) 2017-04-21 23:31:59 -07:00
David Fowler a749939be4 Clean up libuv connection (#1726)
* Clean up libuv connection
- Cancel all pending flushes on the input writer before
disposing the stream handle.
- Complete the pipe before disposing the socket
- Added logging for connection pause/resume.
- Added test
2017-04-21 13:13:05 -07:00
David Fowler feb9d1281e Tweak libuv shutdown sequence (#1735)
* Tweak libuv shutdown sequence
- Increase timeouts for thread and listener shutdowns
- Remove post.Unreference call from AllowStopRude
2017-04-21 13:12:37 -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 42d82a507d Make all UvRequest objects normal GC handles (#1698)
* Make all UvRequest objects normal GC handles
- This avoids the cost of using GCHandle.Alloc per operation.
- It *does* mean that we need to explicitly dispose UvRequest objects
after using them (which we did before anyways). This change does
add a few try catch statements to make sure we always dispose the UvRequest
if there are synchronous exceptions.
- This is ~1.5% of the overhead in the benchmarks today
- Keep track of all allocated UvRequest objects with a WeakReference in DEBUG
and assert none are kept around after cleaning up.
- Fixed a leak where we don't clean up UvWriteReq objects when writing
to the named pipe.
2017-04-19 15:16:11 -07:00
Pavel Krymets 88890595d1 Define a constant to workaround corefxlab classes asses modifier issue 2017-04-18 09:01:35 -07:00
Cesar Blum Silveira 801a7c7652 Add copyright header to TransportSocketOptions.cs. 2017-04-17 20:47:29 -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
David Fowler 9e37272f06 Clean up the logic in DoReceive 2017-04-14 01:39:56 -07:00
David Fowler aedd061865 Tweaks to socket transport (#1687)
- Style changes: Sort usings, use more var and C#7
- Added ConfigureAwait to stop dead locks with xunit
- Remove duplicate handling of aborts in the receiver
- Handle the case where output ends before input
2017-04-14 01:14: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
Stephen Halter 58284bde5c Don't dispose WriteReqPool and PipeFactory too soon (#1633) 2017-04-08 01:35:02 -07:00
David Fowler 0fd885e5eb Signal the reader after aborting the connection (#1636)
- This will give it a chance to unwind gracefully before failing
with an invalid request.

Fixes #1632
2017-04-08 01:22:06 -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
Stephen Halter f285b18f08 Ensure no data is written to a connection after uv_shutdown (#1600) 2017-04-03 14:58:43 -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
David Fowler c3ad007b0d Fixed regression caused by transport refactoring (#1573)
* Fixed regression caused by transport refactoring
- Libuv should not close the socket until it has started it. Before this was enforced
by calling ReadStart before starting the frame but the flow has changed. Now that closing the connection
is communicated via the pipe, we need to start consuming writes after calling ReadStart.
- Renamed OnSocketClosed to Close and moved dispose and logging into that method.

Fixes #1571
2017-03-30 09:33:28 -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
Pranav K d6d13a0986 Remove net451 as a cross-compile target 2017-03-24 07:44:11 -07:00
David Fowler f090b7a9c6 React to corefxlab changes (#1539)
- Removed use of TryRead and follow the pin and use pattern in the other APIs

https://github.com/dotnet/corefxlab/pull/1348
2017-03-23 06:52:24 -07:00
David Fowler c65734667a Optimize calls into StreamSocketOuput to WriteFast further (#1538)
* Optimize calls into StreamSocketOuput to WriteFast further
- Added overloads to array, offset, length to avoid implicit conversions to
ReadOnlySpan.
- Use similar optimizations for multi buffer writes for strings and ints
- Use ref locals in multi write instead of pointers and pinning
2017-03-22 02:16:28 -07:00
Cesar Blum Silveira 72587baac3 Check that MaxRequestBufferSize is greater than or equal to MaxRequestHeadersTotalSize (#1491). 2017-03-21 19:25:56 -07:00
David Fowler 5fad3c7a3e Remove async from WriteAsync in SocketOutput (#1531)
- SocketOutput.WriteAsync will be synchronous for a majority of cases
(until you reach the limit) so no need to pay the async state machine
cost until then.
2017-03-21 09:52:24 -07:00
Ben Adams 32d6b42964 Respond to corefxlab rename (build break) (#1529) 2017-03-21 08:43:49 -07:00
Ben Adams 24ed93288e Use for rather than foreach on List (#1523)
List enumerator is full fat
2017-03-21 03:26:58 -07:00
David Fowler f546f16356 Forgot to WriteFast in SocketOutput (#1527) 2017-03-21 03:21:31 -07:00
David Fowler cf576559b6 Fix write after close (#1526)
- Change Alloc to be a Write with a callback that exposes the WritableBuffer.
This allows the ISocketOutput to implementation to not call the callback if
the underlying socket is dead.
- Added a new functional test
2017-03-20 23:58:26 -07:00
Cesar Blum Silveira 3b40ba52ca Check if request is aborted before verifying response bytes written (#1498). 2017-03-20 16:02:25 -07:00
Stephen Halter 8923b0da70 Use correct config for response buffer limit (#1516) 2017-03-20 15:43:55 -07:00
David Fowler 39819d6708 Added fast path for single memory ReadableBuffer (#1512)
* Special case single buffer
* Added fast path for single span buffers in UvWriteReq
2017-03-20 00:11:41 -07:00
David Fowler 2ed456fd68 Faster Write implementation using cpblk (#1511)
* Faster Write implementation
- Use Unsafe.CopyBlockUnaligned to copy bytes to the
WritableBuffer. This is temporary until we get newer
corefx bits with a better span.CopyTo implementation.
- Remove WritableBufferExtensions from Performance project
- Split method into WriteFast and WriteMultiBuffer
- Cache the span for the common case where
the buffer is non empty.
- Use ref locals instead of pinning pointers in fast path
2017-03-19 12:44:01 -07:00
David Fowler f1e0143d51 React to corefxlab changes (#1510)
* React to latest CoreFxLab changes
2017-03-19 01:31:11 -07:00
David Fowler f6e5e74d95 Update packages (#1509)
* Update packages
* React to API changes in corefxlab
2017-03-18 15:42:01 -07:00
Justin Van Patten 6d2001c67a Remove explicit static constructors (#1483)
Explicit static cctors cause the C# compiler to not mark types as
beforefieldinit, which means the JIT will add checks to each static
method and instance constructor of the type to make sure that the static
constructor was previously called.
2017-03-18 12:42:31 -07:00
Ben Adams 5b814a55ac Speed up WritableBuffer.WriteXxx (#1504)
* Speed up WritableBuffer.WriteAscii
* Add Benchmarks
* Non-standard header vals are still ascii
* Speedup WriteNumeric
* Don't advance for write
* Remove cruft
2017-03-18 12:25:10 -07:00
David Fowler f4c6e0b151 Feedback from SocketOutput port (#1502)
- Fix naming convention in LibuvAwaitable
- Remove case statement in SocketOutput
2017-03-18 01:21:31 -07:00
Pavel Krymets 07cbf7faa9 Use pipelines for SocketOutput
- Changed socket output to be based on pipelines
- Changed connection filter glue to be based on pipelines
- Codegen that used `MemoryPoolIterator` for output now uses `WritableBuffer`
- Made `UvWriteReq` async/await friendly with `LibuvAwaitable<T>`
- Deleted MemoryPool and friends
2017-03-18 00:26:00 -07:00
Cesar Blum Silveira 2ef3804578 Span-based RemoveDotSegments (#1448) 2017-03-17 14:42:13 -07:00
Cesar Blum Silveira 632780dd16 Remove splitting of path and path base (#1050). 2017-03-15 09:57:33 -07:00
Nate McMaster d4c0d4b81e Adds an EventSource named 'Microsoft-AspNetCore-Server-Kestrel' with the following event and properties:
ConnectionStart:
 - connectionId
 - scheme
 - localEndPoint
 - remoteEndPoint

ConnectionStop:
 - connectionId
2017-03-14 16:59:11 -07:00
Nate McMaster 64f84811bd Fix incorrect debug asserts 2017-03-14 11:45:04 -07:00
Nate McMaster 5073d4fdaf Re-add .NET Framework to tests and other cleanup (#1494) 2017-03-14 11:02:49 -07:00
Ben Adams b94912bcb1 InitializeHeaders only at start of parsing/Fix remaining (#1488)
* Don't reinitialize header collection each loop
* Correct remaining tracking value
* Add tests
2017-03-13 15:32:28 -07:00
Cesar Blum Silveira 49f09d5a25 Log rejected request targets. 2017-03-12 18:37:08 -07:00
Justin Van Patten b612da4e6c Avoid an unnecessary closure allocation in ListenerSecondary (#1485)
The tcs is being passed as the state, so use it from the state instead
of closing over it.
2017-03-12 12:20:41 -07:00
Justin Van Patten a26f96237b Specify StringComparison when calling string.StartsWith (#1484)
StartsWith does a culture-sensitive comparison by default. An ordinal
comparison makes more sense here.
2017-03-11 22:31:42 -08:00
arespr d755f6183a Merge branch 'dev' into knownmethods-optimizations 2017-03-11 22:50:58 +01:00
Nate McMaster 49b328d4c2 Handle absolute, asterisk, and authority-form request targets
Improves compliance with RFC 7230 on the expected handling of requests
that have URI or asterisk in the request target.

This means rejecting asterisk requests that are not OPTIONS and rejecting
authority-form requests taht are not CONNECT.

This also means the server will handle the path and query on targets
with absolute URIs as request-targets.
2017-03-09 16:54:12 -08:00
Ben Adams 941d396942 Speed up ParseRequestLine (#1463) 2017-03-08 19:27:56 -08:00
Cesar Blum Silveira bb973decb8 Unify header rejection messages.
- Log bad headers with escaped non-vchar characters
2017-03-08 15:27:44 -08:00
arespr e9250323e0 update GeneratedCodeTests 2017-03-08 22:20:43 +01:00
David Fowler dbcf34388e Remove dependency on Utf8String (#1466)
- Also remove System.IO.Pipelines.Text.Primitives
2017-03-08 12:38:55 -08:00
arespr 0bca84a268 Add HttpUtilities to CodeGenerator 2017-03-08 19:17:12 +01:00
arespr 0a45cbbb95 Merge branch 'dev' into knownmethods-optimizations 2017-03-08 19:09:00 +01:00
Cesar Blum Silveira e25eb418bb Change non-printable char representation in log messages from <0xXX> to \xXX. 2017-03-08 10:05:53 -08:00
David Fowler 1f0bb14546 Clean up left over code from port to pipelines (#1465)
- Remove unused methods in PipelineExtensions
- Remove AwaitableThreadPool since we dispatch reads
2017-03-08 08:43:11 -08:00
Cesar Blum Silveira 5743d740b4 Convert HTTP parsing FrameTests to IHttpParser tests (#1416).
- Also fix an issue in KestrelHttpParser where "Header: \r\n" is
  parsed with a value of " " instead of "".
2017-03-07 15:51:11 -08:00
Ben Adams e2f8c226ef Simplify TakeSingleHeader and Vectorize (#1457)
* Sanitize unsafe code
* Vectorize
* Extract Contains and add more tests
2017-03-07 13:30:57 -08:00
Pavel Krymets 1294c00618 Cleanup unused code (#1458) 2017-03-07 11:52:45 -08:00
David Fowler 02a4342908 Made changes to TakeSingleHeader (#1453)
* Made changes to TakeSingleHeader
- Remove state machine and just parse in place
- Inline OnHeader into TakeSingleHeader
- Use IndexOfVectorized instead of custom indexof
- Normalize header whitespace error
- Combine IndexOf and IndexOfAny into a single IndexOfNameEnd call
2017-03-07 08:58:55 -08:00
John Luo 06134bc6e0 Add IPv6 loopback address by default #1434 2017-03-06 18:02:28 -08:00
David Fowler 537b06f025 Interleave multispan and single span code path (#1442)
- Attempt at making the reader better for multispan parsing
- Try tighter inner loop
- Fix boundary case and clean code up
- Update the cursor once instead of after every header
- Fix errors with not updating consumed state on incomplete header payload
- Filled a test hole, removed a condition that should never happen
- Avoid struct copies every iteration when parsing headers
2017-03-06 09:06:28 -08:00
David Fowler da763b4873 Use ascii decoding routine that disallows null chars (#1445)
* Use ascii decoding routine that disallows null chars
- GetAsciiString() in newer corefxlab builds allows 0 (which is a valid
ascii char). To avoid future regressions, GetAsciiStringNonNullCharacters()
was added and used in place of GetAsciiString() when interpreting the
request line and headers
- Make GetAsciiStringNonNullCharacters return empty instead of null
2017-03-04 11:26:32 -08:00
David Fowler 20f75605ca Workaround rogue System.IO.Pipelines on nuget.org 2017-03-03 22:35:41 -08:00
Stephen Halter ac60f13312 Modify RequestProcessingAsync to call single parse method (#1427)
* Modify RequestProcessingAsync to call single parse method
* Fix bad request logging
2017-03-03 14:43:32 -08:00
David Fowler 1d685e195e Parser cleanup and remove line continuation header error (#1431)
- Cleaned up some parsing logic (removed locals etc)
- Removing line continuation errors cleaned up code duplication
a little bit
2017-03-03 10:04:44 -08:00
arespr ac5fd3f29f PR feetback 2017-03-02 22:45:36 +01:00
arespr bb74a6ce34 address PR feetback, fix unit tests for invalid known methods 2017-03-02 22:04:43 +01:00
David Fowler 8929b40527 Single span optimizations (#1421)
- Added a fast path for single span in the start line parsing
- Added a fast path for single span header parsing
- Changed the out header loop to be pointer based (instead of slicing)
2017-03-02 12:17:39 -08:00
arespr 96fead6282 better GetKnownMethodIndex, unit tests, benchmark repair 2017-03-02 20:58:18 +01:00
David Fowler ca31627a5e Parser clean up (#1419)
- Remove stackalloc
- Remove extra Move in ParseRequestLine
2017-03-01 22:33:37 -08:00
Pavel Krymets f2a00da811 Loop over bytes inside states of parser state machine (#1417) 2017-03-01 18:18:34 -08:00
arespr b89415d9b2 knownmethods optimizations 2017-03-02 03:10:00 +01: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
Krzysztof Cwalina c56de066d3 Optimized parsing GET verb and version (#1399)
* Optimized parsing GET verb
* optimized http version parsing
* Added microbenchmarks for GetKnownMethod and GetKnownVersion
2017-02-28 17:02:52 -08:00
John Luo 6ad9f3e8b0 Reacting to HeaderUtitilities renames 2017-02-28 14:50:02 -08:00
Cesar Blum Silveira 568aaff9c4 Improve HTTP parsing tests (#1393).
- Add several more test cases
- Share data between functional and unit tests
2017-02-28 14:23:27 -08:00
Stephen Halter fde0f6b2fc Add an option to Kestrel to disable threadpool dispatching 2017-02-28 10:14:58 -08:00
David Fowler c6705d8693 Convert TakeStartLine and TakeMessageHeaders to be state machines (#1401)
- Less passes over the buffer
- Single pass to find all start line delimiters instead
of calling IndexOf multiple times.
- Made TakeStartLine and TakeMessageHeaders a state machine
- Only check length against remaining bytes once
- Change variable names to match TakeStartLine
- Use ReadableBuffer.First.Span instead of ToSpan()
- Added test for missing path with a querystring
2017-02-27 11:55:30 -08:00
David Fowler 5692f51bf7 Revert "Revert "Use Spans to parse the start line and headers (#1394)""
This reverts commit 19c3107deb.
2017-02-24 10:22:05 -08:00
David Fowler 19c3107deb Revert "Use Spans to parse the start line and headers (#1394)"
This reverts commit 8140b8cdfe.
2017-02-24 10:03:32 -08:00
David Fowler 8140b8cdfe Use Spans to parse the start line and headers (#1394)
* Use Spans to parse the start line and headers
- Use `Span<byte>` to parse the start line and headers
2017-02-23 23:02:29 -08:00
Stephen Halter 39b536b402 Don't treat canceled reads as end of input 2017-02-23 10:05:53 -08:00
Stephen Halter 7d3bcd2bf8 Avoid unobserved exceptions
- Don't throw from AdaptedPipeline.ReadInputAsync
- Watch for unobserved exceptions in SampleApp
2017-02-22 16:12:20 -08:00
David Fowler ba549502e1 Use the IThreadPool as the ReaderScheduler (#1372)
- This is what socket input did, also using
ThreadPool.QueueUserWorkItem is better than Task.Run for this
scenario and avoids a bunch of overhead.
2017-02-21 21:09:23 -08:00
Pavel Krymets 824ef2c937 Input Pipeline migration (#1277) 2017-02-17 15:38:13 -08:00
Nate McMaster 932b6ed53a
Cleanup MSBuild conversion
Remove runtimeconfig.template.json
Remove ToolsVersion attribute
Use repo.targets instead of makefile.shade
Rename code gen app to shorter name
Use GetOSPlatform task
Upgrade tests to .NET Framework 4.5.2
Cleanup solution configurations. Set the class libraries to AnyCPU even when on the x86 or x64 solution config.
2017-02-16 09:44:58 -08:00
Nate McMaster 708630fd23 Downgrade to stable packages 2017-02-15 14:22:38 -08:00
Stephen Halter e9e0cf7325 Prevent ODE when ReadStart/Stop() is queued after disposal 2017-02-07 00:26:05 -08:00
Stephen Halter 5124adf450 Better report Kestrel crashing errors 2017-02-07 00:26:00 -08:00
Cesar Blum Silveira 1a2c438899 Upgrade to RC.3 2017-01-31 16:23:23 -08:00
Ben Adams ecca980c91 Implement IHeaderDictionary.ContentLength 2017-01-24 14:55:48 -08:00
Ben Adams cac6ade7c9 Implement Stream Flush+FlushAsync fully
Streams should pass through the flush and not assume the underlying
Stream's Flush behaviour
2017-01-23 13:51:57 +00:00
Stephen Halter f32058c5c3 Warn instead of throw when ignoring IServerAddressesFeature
- Throwing could be too much when IServerAddressesFeature URLs come from VS
- Listen on 127.0.0.1:5000 by default

https://github.com/aspnet/Hosting/issues/917
2017-01-19 11:36:19 -08:00
Stephen Halter c4762cdfd5 Better handle OnHeartbeat in 32-bit environments
- Prevent potential overflow when casting a long to an IntPtr
2017-01-17 16:57:52 -08:00
Cesar Blum Silveira 89a63d190e Don't close connection when Content-Length set but no bytes written. 2017-01-12 12:38:15 -08:00
Cesar Blum Silveira e26f91a392 Call OnStarting before verifying response length (#1289). 2017-01-10 14:24:44 -08:00
John Luo 57b368566d Use StatusCode instead of three digit numbers for status codes 2017-01-09 10:09:54 -08:00
Cesar Blum Silveira 6d7ddc45ef Fix deadlock in SocketOutput (#1278). 2017-01-06 20:33:35 -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 b46e48fe01 Merge branch 'yves57/stringvalues-for' into dev 2016-12-28 14:44:46 -08:00
Pranav K 5b8f7c2b2b Updating to 4.4 CoreFx packages 2016-12-21 22:22:13 -08:00
Cesar Blum Silveira b41c4078bd Abort connections not closed during shutdown (#1112). 2016-12-20 14:44:34 -08:00
Pavel Krymets 8b44e8e382 Prevent closure allocations in OnHeartbeat (#1261) 2016-12-16 14:42:30 -08:00
Cesar Blum Silveira cedbe76f52 Abort request on client FIN (#1139). 2016-12-13 12:03:33 -08:00
Cesar Blum Silveira defcbdb907 Revert "Add MaxRequestBodySize limit (#478)."
This reverts commit e53a87be9c.
2016-12-09 16:30:12 -08:00
John Luo 859816bb53 Update ParseContentLength to remove unnecessary casting and unsafe 2016-12-09 11:39:25 -08:00
John Luo 4da06e8acd Move Int64 parsing logic to HttpAbstractions 2016-12-08 17:22:21 -08:00
Cesar Blum Silveira e53a87be9c Add MaxRequestBodySize limit (#478). 2016-12-05 17:06:57 -08:00
Yves57 dbaa01830b Replace 'foreach' by 'for' in StringValues (faster) 2016-11-29 22:33:18 +01:00
Cesar Blum Silveira f918279873 Merge branch 'khellang/proxy-authenticate-typo' into dev 2016-11-29 10:32:16 -08:00
Chris R 53e5c3d56c #1001 don't log stack traces for localhost bind failures. 2016-11-28 16:35:14 -08:00
Kristian Hellang e316898c9f Added missing copyright header 2016-11-23 09:17:03 +01:00
Pavel Krymets e55c62444b Refactor FrameTests and rename SocketInput SocketOutput properties (#1229) 2016-11-22 16:36:36 -08:00
Ben Adams 2bf5a966cd Fast path and inline HttpVersion.set 2016-11-22 15:26:38 -08:00
Kristian Hellang a0f5585d3f Fixed typo; Proxy-Authenticate #1223 2016-11-22 13:08:17 +01:00
Ben Adams 2eba4017c1 MemoryPoolIterator feedback 2016-11-21 22:48:58 +00:00
Ben Adams ef5ad3deea defaullt(MemoryPoolIterator) test coverage 2016-11-21 22:48:58 +00:00
Ben Adams 2011a27bde Use ternary op rather than lazy and 2016-11-21 22:48:57 +00:00
Ben Adams 8ce47fb8b6 Move perf, share code 2016-11-21 22:48:57 +00:00
Ben Adams 5041d6c291 wasLastBlock adjustments 2016-11-21 22:48:57 +00:00
Ben Adams 7ab4442392 Feedback + Cleanup 2016-11-21 22:48:57 +00:00
Ben Adams 4cdcca212e Don't inline slow paths 2016-11-21 22:48:57 +00:00
Ben Adams 12e2f30577 MemoryPoolIterator byref structs 2016-11-21 22:48:57 +00:00
Ben Adams 53f361160e MemoryPoolIterator fast paths 2016-11-21 22:48:57 +00:00
Ben Adams 8bcbfb9971 Only LocateFirstFoundByte once 2016-11-21 22:48:57 +00:00
Ben Adams 28a21fa7a9 Move vectors closer to use 2016-11-21 22:48:57 +00:00
Ben Adams 00a63537cf And=> xor, powerOfTwoToHighByte to const 2016-11-21 22:48:57 +00:00
Ben Adams 97d4406614 Use Vector<byte>.ctor workaround 2016-11-21 22:48:57 +00:00
Ben Adams 972d978d11 Swap for vector loop unroll detection 2016-11-21 22:48:57 +00:00
Ben Adams 9eb01d1c57 Reduce Vector register pressure by not overlapping 2016-11-21 22:48:57 +00:00
Ben Adams 4f7977d440 Use PowerOfTwoToHighByte for FindFirstEqualByte 2016-11-21 22:48:57 +00:00
Stephen Halter 0c26fc9f41 Merge branch 'rel/1.1.0' into dev 2016-11-11 15:16:48 -08:00
Stephen Halter f1d0fafaa4 Better filter clients connecting to Kestrel's dispatch pipes 2016-11-11 14:57:17 -08:00
Stephen Halter 4a1db74568 Merge branch 'rel/1.1.0' into dev 2016-11-09 14:29:31 -08:00
Stephen Halter e780ad9516 Ensure clients connecting to Kestrel's dispatch pipe are listeners 2016-11-09 14:26:47 -08:00
Pranav K 9d081d17e5 Updating versions to 1.2.0-* 2016-11-09 14:18:16 -08:00
Stephen Halter 757952d4d3 Always flush headers on first response write (#1202). 2016-11-09 14:02:50 -08:00
Stephen Halter c0e75dcbf8 Always flush headers on first response write (#1202). 2016-11-09 13:59:12 -08:00
Stephen Halter 194059a198 Implement Begin/End Read/Write methods in LoggingStream
- This allows the reads and writes from SslStream to be logged on desktop .NET
2016-11-04 21:38:57 -07:00
Stephen Halter 0d559468f1 Make connection reset logs less scary
- Particularly between requests, connection resets aren't that abnormal.
2016-11-04 21:36:51 -07:00
Cesar Blum Silveira a83bbcfba7 Prevent block leak when socket is closed before connection filter is applied. 2016-11-04 20:56:01 -07:00
Cesar Blum Silveira a1c598733b Reject POST and PUT requests with no Content-Length or Transfer-Encoding (#1130). 2016-11-04 18:04:27 -07:00
jacalvar ed98894c93 Created public API baselines 2016-11-04 17:16:22 -07:00
Stephen Halter 6cbbb73ca7 Protect against NullReferenceException in Frame.StopStreams() 2016-11-04 16:01:07 -07:00
Stephen Halter b3aca0413c Avoid zero-length writes to flush connection filter stream
- This works around a zero-length write bug in SslStream.
- We already assume connection filter streams auto flush.

#1195
2016-11-04 15:43:35 -07:00
Pranav K 0dcfa2a3fd Updating to Libuv 1.9.1 2016-11-03 10:08:01 -07:00
Ben Adams 2adb6ff955 Interlocked.Read -> Volatile.Read 2016-11-01 18:06:00 -04:00
Cesar Blum Silveira 29408956f9 Handle tokens in Transfer-Encoding header (#1181). 2016-10-31 13:57:34 -07:00
Stephen Halter 5e97c63467 Throw PlatformNotSupportedException on big-endian platforms 2016-10-28 14:51:55 -07:00
Stephen Halter d475d41f71 Fix boundary cases in MemoryPoolIterator.(Try)PeekLong()
- Fix edge case where the iterator is at the very end of a block.
- Fix edge case where one bits where improperly filled in on a right shift.
- Don't use -1 to represent failure. Use bool and an out parameter instead.
2016-10-28 14:51:47 -07:00
Cesar Blum Silveira 1ffad5ca38 Handle multiple tokens in Connection header (#1170). 2016-10-27 12:19:43 -07:00
Cesar Blum Silveira d64b4c7acb Control-flow simplification in Frame.CreateResponseHeader() (#1168). 2016-10-24 11:07:06 -07:00
Nathan Anderson 610601cc6e test fixes and whitespace changes to generated code 2016-10-20 15:23:03 -07:00
Nathan Anderson 11ed34f229 add header ordering and short circuits to known headers
refactor known header changes

- create template string from Append switch
- add a check to ClearFast to bail out if too many headers are set
2016-10-19 15:49:01 -07:00
Cesar Blum Silveira fff0adeaaf Faster response Content-Length parsing. 2016-10-18 15:57:40 -07:00
Cesar Blum Silveira 78584799a4 Separate request rejection from bad request state setting. 2016-10-17 15:16:50 -07:00
Mike Harder f1071dea50 Set StatusCode before disposing HttpContext (#876) 2016-10-17 15:16:43 -07:00
Cesar Blum Silveira bf94f8526a Remove TCP Loopback Fast Path code (#1147). 2016-10-12 11:41:57 -07:00
Cesar Blum Silveira ffc3eb3afd HEAD response can include Content-Length header. 2016-10-12 11:38:18 -07:00
Stephen Halter ce6e65b1d7 Don't take SocketOutput's _contextLock to return written blocks 2016-10-11 16:39:13 -07:00
Cesar Blum Silveira a15b1e2805 Update cached Content-Length when setting raw header. 2016-10-11 13:55:05 -07:00
Cesar Blum Silveira f8813a600d Handle response content length mismatches (#175). 2016-10-11 13:25:22 -07:00
Cesar Blum Silveira 6c2532682a Merge branch 'benaadams/callstack' into dev 2016-10-10 14:42:22 -07:00
Cesar Blum Silveira 3177ba0aae Wait for frame loop completion to dispose connection stream (#1156). 2016-10-10 10:16:03 -07:00
Ben Adams adc3e63ecc Improve callstack for LoggingThreadPool 2016-10-08 05:14:00 +01:00
Kristian Hellang 03f8a7a217 Use HeaderUtilities.FormatDate in DateHeaderValueManager (#1132) 2016-10-06 11:56:49 -07:00
Cesar Blum Silveira 2c94884da9 Include address in error message when address already in use (#1086). 2016-10-05 14:23:09 -07:00
Pranav K 91497621c9 Updating partner package versions 2016-10-03 19:59:39 -07:00
Cesar Blum Silveira a2439105ae Refactor request line validation and error reporting (#1116). 2016-10-03 16:54:51 -07:00
Cesar Blum Silveira 4117ad8a1e Refactor non-body response handling.
- Add functional tests
- Remove BadHttpResponse, ResponseRejectionReasons and TestFrameProtectedMembers
- Chunk non-keepalive HTTP/1.1 responses
- Set _canHaveBody to true when StatusCode == 101
- Add test to check that upgraded connections are always closed when the app
  is done
- Log writes on responses to HEAD requests only once.
2016-10-03 16:46:59 -07:00
Ben Adams e7e6b896ba Don't emit TE header or body for non-body responses 2016-10-03 15:54:14 -07:00
Cesar Blum Silveira e8fa40235b Remove unused variable in MemoryPoolIterator.Seek() (#1137). 2016-10-03 14:22:10 -07:00
Mikael Mengistu 12adc7de9d Refactored to use the fields from the HttpMethods class
* Reacting to PR comments
2016-09-29 12:19:26 -07:00
Ben Adams 310411075f Slimmer locks 2016-09-28 15:33:34 -07:00
Cesar Blum Silveira 09fda749b0 Don't reset frame state when connection is aborted (#1103). 2016-09-28 15:06:22 -07:00
Cesar Blum Silveira 73656f6503 Assume zero length on non-keepalive requests without Content-Length or Transfer-Encoding (#1104). 2016-09-28 12:30:53 -07:00
Cesar Blum Silveira 0312da7df3 Add request headers timeout (#1110). 2016-09-27 17:08:02 -07:00
Stephen Halter 7b2f7b94ab Return last block from SocketOutput when data is fully written
- This reduces Kestrel's memory usage for idle connections.
2016-09-27 15:57:45 -07:00
Stephen Halter 0edf36bd21 Return last block from SocketInput when data is fully consumed
- This reduces Kestrel's memory usage for idle connections.
2016-09-27 15:57:45 -07:00
Cesar Blum Silveira 375e8b7022 Change context relationships from inheritance to composition. 2016-09-27 11:53:06 -07:00
David Fowler 78c859d7ea Turn on warnings as errors 2016-09-25 12:25:12 -07:00
David Fowler 67930753df Merge pull request #1123 from svick/sockaddr-sequential
Specify sequential layout to avoid warning
2016-09-25 10:49:10 -07:00
Petr Onderka 782f96572d Specify sequential layout to avoid warning 2016-09-25 18:13:42 +02:00
Cesar Blum Silveira 49ff98f8cb More specific response status codes for errors (#653).
- 414 when request line exceeds size limit
- 431 when request headers exceed size or count limits
- 505 when request line contains unsupported HTTP version
2016-09-22 12:13:14 -07:00
Stephen Halter 63509b9e10 Make FrameRequestStream.CopyToAsync(...) copyless
- Add tests for when the CopyToAsync destinationStream throws.
- Add test to verify the destination stream sees the same array written to by
  the producer.
2016-09-20 11:54:58 -07:00
Cesar Blum Silveira 1a273f5a34 Improve keep-alive timeout.
- Track time more accurately
- Control timeout in Connection instead of Frame
2016-09-14 20:57:16 -07:00
Stephen Halter 2fbf0c6281 Merge branch 'DamirAinullin/single-initialize' into dev 2016-09-12 10:34:35 -07:00
Cesar Blum Silveira 8c513402a3 Always call ConsumingComplete() with furthest examined position (#1095). 2016-09-10 20:05:14 -07:00
Pavel Krymets c777a9efea Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#1089)
Instead of Task.FromResult(0)
2016-09-09 15:57:33 -07:00
DamirAinullin 0491b49268 Remove double initializing of variable _field3 2016-09-07 14:23:06 +03:00
Cesar Blum Silveira f2085b1968 Add keep-alive timeout (#464). 2016-09-06 12:48:47 -07:00
Cesar Blum Silveira 19f8958fa8 Move TestServer to shared directory. 2016-09-06 12:47:24 -07:00
David Fowler 6795ca2f78 Make the char array for utf8 decoding smaller 2016-08-31 18:54:15 -07:00
Stephen Halter 1ecef8094a Make Kestrel's response buffer limit configurable 2016-08-30 16:01:42 -07:00
Stephen Halter acfcafb6e1 Ensure MockLibuv.OnPostTask doesn't complete too early 2016-08-29 20:53:00 -07:00
Stephen Halter 0742d113be Make all calls to ThreadPool.QueueUserWorkItem through IThreadPool
- This allows SocketOutputTests to cause QUWI to exec synchronously
- To avoid allocations, the logger can't be captured making it "unsafe"
2016-08-29 20:52:47 -07:00
Stephen Halter 08d7f66108 Merge branch 'benaadams/less-unsafe' into dev 2016-08-26 14:44:18 -07:00
Ben Adams be51e5aecb Remove unneeded unsafe modifiers 2016-08-25 08:07:15 +01:00
Ben Adams 7dc0a8c7bd Return count from trywrite 2016-08-25 07:58:36 +01:00
Ben Adams af73e519c1 Comment inlinability changes 2016-08-25 07:53:01 +01:00
Ben Adams 40636998d7 Improve inlinability of libuv success checking 2016-08-21 13:48:35 +01:00
Stephen Halter 7bd30ea693 Log all startup errors in KestrelServer 2016-08-18 14:52:26 -07:00
Stephen Halter 972be6e8c1 Disable automatic chunking for all non keep-alive requests
- Fixes a bug where Upgrade requests (e.g. WebSockets) would be chunked
- Allows chunking to be disabled by setting "Connection: close" on the response
2016-08-17 12:39:18 -07:00
Stephen Halter 16fbb94c44 Automatically chunk and set 0 Content-Length for non keep-alive responses 2016-08-15 16:27:54 -07:00
Stephen Halter 5f4e60bf8d Always set "Connection: close" header for non keep-alive responses 2016-08-15 16:27:54 -07:00
Cesar Blum Silveira 08a91f17bf Call OnStarting and OnCompleted callbacks in LIFO order (#1042). 2016-08-10 14:52:05 -07:00
Cesar Blum Silveira 08f98f4790 Add header limit options (#475). 2016-08-09 12:31:39 -07:00
Cesar Blum Silveira a5aacd6307 Throw when setting OnStarting after response has already started (#806). 2016-08-08 11:38:06 -07:00
Cesar Blum Silveira 140dc6fcf5 Add obsoletion reason for KestrelServerOptions.MaxRequestBufferSize. 2016-08-04 10:46:42 -07:00
Stephen Halter 9727a4db86 Improve the performance of connection filters
- Buffer connection filter input less by using ProducingStart/Complete
- Simplify FilteredStreamAdapter
2016-08-03 16:45:39 -07:00
Stephen Halter 5aee524768 Ensure Begin/End Read/Write methods are correctly implemented
- Add Begin/End Write methods to FrameResponseStream
- Fix state check of Begin/End Read methods in FrameRequestStream
2016-08-03 16:45:39 -07:00
Stephen Halter 4337d2a4a7 Implement Begin/End Read/Write methods in LibuvStream 2016-08-03 16:45:39 -07:00
Cesar Blum Silveira 8836eec7d8 Limit request line length (#784). 2016-08-03 15:39:16 -07:00
Stephen Halter dfe12223b8 Ensure HTTPS handshake errors aren't logged on socket close 2016-08-03 15:21:57 -07:00
Stephen Halter 1020d69171 Better logging for connection errors during HTTPS handshake 2016-08-03 11:15:15 -07:00
Mike Harder 4ece3f4b68 Change "String." to "string." to match coding convention 2016-08-01 11:09:31 -07:00
Stephen Halter 00a540dcb8 Merge branch 'benaadams/more-block-collect-info' into dev 2016-07-28 16:51:35 -07:00