Swiftpack.co - Package - Kitura/Kitura-NIO

Kitura

Swift 5.0 APIDoc Build Status - Master macOS Linux Apache 2 Slack Status

Kitura-NIO

Kitura-NIO is a SwiftNIO based networking library for Kitura. Kitura-NIO adopts the same API as KituraNet, making the transition from KituraNet to Kitura-NIO seamless. While Kitura-NIO shares some code with Kitura-Net, the core comprising of HTTPServer, ClientRequest/ClientResponse and TLS support have been implemented using SwiftNIO. Kitura-NIO uses NIOSSL for TLS support.

We expect most of our users to require higher level concepts such as routing, templates and middleware. These are not provided in Kitura-NIO. If you want to use those facilities you should be coding at the Kitura level, for this please see the Kitura project. Kitura-NIO, like Kitura-net, underpins Kitura which offers a higher abstraction level to users.

Kitura-NIO 2 has been tested with Swift 5. If you are using Swift 4, please use Kitura-NIO 1. See the release history for details.

Features

  • Port Listening
  • HTTP Server support (request and response)
  • Basic HTTP client support

Using Kitura-NIO

With Kitura 2.5 and future releases, to run on top of Kitura-NIO (instead of Kitura-Net) all you need to do is set an environment variable called KITURA_NIO before building your Kitura application:

    export KITURA_NIO=1 && swift build

If you have already built your Kitura application using Kitura-Net and want to switch to using KITURA_NIO, you need to update the package before building:

    export KITURA_NIO=1 && swift package update && swift build

Using the environment variable we make sure that only one out of Kitura-NIO and Kitura-Net is linked into the final binary.

Please note that though Kitura-NIO has its own GitHub repository, the package name is KituraNet. This is because the Kitura-NIO and Kitura-Net are expected to provide identical APIs, and it makes sense if they share the package name too.

Getting Started

Visit www.kitura.io for reference documentation.

Contributing to Kitura-NIO

We'd be more than happy to receive bug reports, enhancement requests and pull requests!

  1. Clone this repository.

$ git clone https://github.com/IBM-Swift/Kitura-NIO && cd Kitura-NIO

  1. Build and run tests.

$ swift test

You may also want to run the tests in parallel: $ swift test --parallel

In some Linux environments, a low open file limit could cause test failures. See this.

Community

We'd really love to hear feedback from you.

Join the Kitura on Swift Forums or our Slack to meet the team!

License

This library is licensed under Apache 2.0. The full license text is available in LICENSE.

Github

link
Stars: 32

Used By

Total: 0

Releases

2.4.0 - 2019-10-23 10:57:57

What's new

  • Add an API to access the HTTPServer's EventLoopGroup (#225). This was requested for by #224.
  • Fix for #227 (also included in #225)

2.3.0 - 2019-10-08 14:59:51

  • fix: Close active connections while stopping an HTTPServer (#218)
  • feat: Ability to limit request size and connection count (#221)

2.2.0 - 2019-07-29 03:23:32

What's new

  • A nasty race condtion related to WebSocket upgrade has been removed (#217)
  • ClientRequest: HTTP credentials will no longer be included in the ClientRequest.url property. This is a small behaviour change (#208)
  • The creation of HTTPServerRequest objects is now permissible only on the EventLoop on which the underlying HTTP request arrived (#215)
  • ClientRequest: new request headers added for parity with Kitura-net (#213)
  • ClientResponse.status is now updated to reflect the value of ClientResponse.statusCode (#214)

2.1.1 - 2019-06-05 13:03:39

What's new

  • Falling back to building HTTPServerRequest.urlURL using String concatenation instead of URLComponents. This also includes a change to ClientRequest that makes sure we don't percent-encode a URL string twice. (https://github.com/IBM-Swift/Kitura-NIO/pull/199)

2.1.0 - 2019-05-24 09:08:37

What's new

  • Allow Kitura-NIO to only listen on one network address (#205). Kitura listens on every available address/interface. This feature allows Kitura to listen on only on interface (only one network address)

2.0.5 - 2019-05-17 10:03:02

What's new

  • Upgrade to swift-nio 2.1 (#204)

2.0.4 - 2019-05-14 09:38:46

What's new

  • Fix for a WebSocket upgrade failure in Safari based clients(https://github.com/IBM-Swift/Kitura-NIO/pull/203)

2.0.3 - 2019-05-04 04:37:35

What's new

  • Support for query parameters in WebSocket URIs (#201)

1.0.18 - 2019-04-12 14:14:55

2.0.0 - 2019-04-03 18:14:53

What's new

  • Kitura-NIO is now based on NIO2 (#176)
  • Basic client-side and server-side support for Unix Domain Sockets (#187)
  • Added support for negotiating and configuring WebSocket extensions
  • Improved documentation (#177)

Kitura-NIO 2.0 is built upon SwiftNIO 2.0 and builds only with Swift 5.

1.0.15 - 2019-03-20 07:24:19

What's new

  • A few performance improvements related to Swift 5(#166 and #156)
  • Corrections in the access levels of some properties/functions of ClientRequest(#167)
  • Fix for a major regression (#156)
  • Two important fixes for Kitura-CouchDB (#171 and #172)

1.0.12 - 2019-01-18 16:47:48

Minor performance improvements - #146 and #143

1.0.8 - 2019-01-03 17:17:10

In this release we drop the "vX.Y.Z" format for the release name and conform to other Kitura repos that adopt a "X.Y.Z" format.

What's new

  • A few performance improvements (#117, #118 and #120)
  • We now conform to the syntax rules enforced by swiftlint (#121, #122, #123, #124, #125)
  • Jazzy doc generation and Codecov support (#133 and #134)
  • The tests may be run with ephemeral ports which make swift test --parallel possible (#129 and #130)
  • A longstanding flaky test fixed (#131)

Thanks to @nethraravindran for her work on swiftlint, jazzy doc generation and codecov.

v1.0.7 - 2018-12-18 09:28:51

  • Swift 5 support (#116)
  • Performance improvement for calculating utf8-encoded content length (#114)

v1.0.6 - 2018-11-22 15:55:01

What's new

  • Fixes for two data races - HTTPServerRequest.keepAliveState (#99) and one in PipeliningTests (#105)
  • Skip storing an HTTPDummyServerDelegate in the HTTPServer.delegate property (#96)
  • Tests: move libressl installation to PackageBuilder (#97)
  • Performance enhancements: reimplementing HTTServerRequest.url (#112), better headers translation(#113) and IdleStateHandler removal (#104)
  • Other minor code readability enhancements

v1.0.5 - 2018-09-17 06:53:05

What's new

  • Remove all but one fatalError invocations from Kitura-NIO (#90)
  • A bug fix related to the default HTTP version, we now default to 1.1 if the request has no version info (#88)
  • Some refactoring and code cleanup (#88, #89)

v1.0.4 - 2018-09-06 07:34:33

What's new

  • A significant bug-fix around multiple writes to an HTTPServerResponse (#84)
  • Some refactoring to reduce code duplication (#83, #85, #86)

v1.0.3 - 2018-08-29 19:06:50

What's fixed

  • Moving the Kitura router invocation from the event loop to a dispatch queue (#78)
  • Moving ClientRequest.end to a dispatch queue, avoiding wait() calls on the event loop (#79)
  • Fixing a thread leak by shutting down the event loop group created by ClientRequest (#76)
  • Eliminate zlib linker failures on Ubuntu 16.04 docker images(#77)
  • Set SO_REUSEADDR on socket channels to avoid bind errors in Kitura-NIO and Kitura tests (#82)

v1.0.0 - 2018-08-18 18:09:40

What's New

  • KituraNIO renamed to KituraNet
  • Better handling of WebSocket upgrade errors