Commit Graph

16 Commits

Author SHA1 Message Date
Cesar Blum Silveira da7bc24eec Add request parsing regression tests. 2017-09-13 14:49:45 -07:00
Nate McMaster c2f15fcac3 Move user-facing strings into resource files 2017-04-26 17:22:55 -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
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
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
Cesar Blum Silveira 2ef3804578 Span-based RemoveDotSegments (#1448) 2017-03-17 14:42:13 -07:00
Cesar Blum Silveira 49f09d5a25 Log rejected request targets. 2017-03-12 18:37:08 -07: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
Cesar Blum Silveira bb973decb8 Unify header rejection messages.
- Log bad headers with escaped non-vchar characters
2017-03-08 15:27:44 -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
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
Cesar Blum Silveira 11c7eb5665 Verify all request rejections are logged (#1295). 2017-03-06 12:05:38 -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
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