Commit Graph

633 Commits

Author SHA1 Message Date
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
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
Nate McMaster eb1301f28d Skip HostName binding test when network is unreachable 2017-04-25 14:33:06 -07:00
Pranav K 5b976a9fa3 Use Bundled NETStandard.Library \ NETCoreApp versions instead of explicitly specifying one 2017-04-25 12:51:48 -07:00
Stephen Halter a4def946a6 Fix flaky 400 response tests (#1758) 2017-04-24 23:48:47 -07:00
Pavel Krymets e3e78bc461 Fix LibuvOutputConsumerTests (#1757)
* Fix LibuvOutputConsumerTests
2017-04-24 17:37:30 -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
Nate McMaster 089ff49643 Put hostname address registration into separate test 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
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 dcea15dba7 Skipped newly failing AddressRegistration tests failing tests on OSX and Linux (#1732)
* Unblock CI
2017-04-21 01:54:44 -07:00
Stephen Halter a14eabce9a RequestTests and ResponseTests cleanup (#1723) 2017-04-20 16:33:05 -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
Stephen Halter bebba2a113 Make UnrootedConnectionsGetRemovedFromHeartbeat test less flaky (#1727) 2017-04-20 10:58:48 -07:00
David Fowler d0743806d8 Disable UnrootedConnectionsGetRemovedFromHeartbeat because it's flaky 2017-04-20 10:21:20 -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
David Fowler d40dbb81ea Fixed broken tests that leak UvWriteReq 2017-04-19 17:50:43 -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
Stephen Halter e4ba1d01ce Ensure that KeepAliveTimeoutTests do not run with sync context (#1718)
- With Task.Delay(1).ConfigureAwait(false) there's a race where
  Task.IsCompleted could already be true by the time it's evaluated.
2017-04-18 17:20:59 -07:00
Cesar Blum Silveira a0743650ef Don't use hardcoded ports in PreferHostingUrls tests (#1701). 2017-04-17 20:47:46 -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 de6da7c757 Add ConfigureAwait(false) to test helpers (#1699)
* Add ConfigureAwait(false) to test helpers
2017-04-17 11:33:27 -07:00
David Fowler 6a403d231e Clean up IThreadPool interface (#1696)
- Remove tcs completion methods
2017-04-15 19:04:44 -07:00
David Fowler 0ac478858d Fixed benchmarks after refactoring
- Added MockTimeoutControl
2017-04-14 20:15:16 -07:00
David Fowler 051c251e53 Fixed flaky test
- Increase the interval to avoid chances of overlapping
2017-04-14 19:25:32 -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
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
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
Stephen Halter db159190bd Don't fail tests if port 5000 is in use (#1650) 2017-04-11 23:13:59 -07:00
Mike Harder 99278c4691 Workaround for "Explicit RID still required for .NET Framework test projects"
- Addresses #1617
2017-04-10 22:03:00 -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
Stephen Halter 1faaefef30 Fix Libuv.Tests directory name (#1646) 2017-04-10 11:43:12 -07:00
Ben Adams 2863cca8ca FrameFeatureCollection benchmark (#1643) 2017-04-09 16:02:18 -07:00
David Fowler d92c55dbfc Fix spelling nit 2017-04-08 01:50:25 -07:00
Stephen Halter 58284bde5c Don't dispose WriteReqPool and PipeFactory too soon (#1633) 2017-04-08 01:35:02 -07:00
Cesar Blum Silveira 27584dc620 Add new MessageBody tests and refactor some existing ones.
- No need to test with FIN since we consider that an error
- Consolidate HTTP/1.0 and HTTP/1.1 tests that were the same except for the HTTP version
- Add a few new tests
2017-04-07 20:26:34 -07:00
Pavel Krymets 53b0eea2ec Use writable buffer writer (#1564) 2017-04-07 14:40:10 -07:00