Commit Graph

491 Commits

Author SHA1 Message Date
Johannes Weiß 2cac305e3e work bug in latest Swift 4.1 with closures taking `()` (SR-7191) (#149)
Motivation:

In a few instances, we have code that ignores a `()` argument in a
closure with this syntax:

    { (_: Void) in

whilst that's a bit odd, it shouldn't be wrong and Swift 4.0.x is also
totally happy with it. The latest Swift 4.1 candidates however are not
and also there's a better way of spelling this:

    { () in

and in some cases even just

    {

Modifications:

Removed instances of `{ (_: Void) in`

Result:

Compiles with `swift-4.1-DEVELOPMENT-SNAPSHOT-2018-03-12-a`
2018-03-14 08:41:03 +01:00
Cory Benfield b542775605 Add initial websocket codec. (#109)
Motivation:

Websockets is a major protocol in use on the web today, and is
particularly valuable in applications that use asynchronous I/O
as it allows servers to keep connections open for long periods of
time for fully-duplex communication.

Users of NIO should be able to build websocket clients and servers
without too much difficulty.

Modifications:

Provided a WebsocketFrameEncoder and Decoder that can serialize and
deserialize Websocket frames.

Result:

Easier use of websockets.
2018-03-13 17:24:54 +01:00
Cory Benfield 860a7d40a3 Add channel handler for server side pipelining. (#62)
Motivation:

HTTP pipelining can be tricky to handle properly on the server side.
In particular, it's very easy to write out of order or inconsistently
mutate state. Users often need help to handle this appropriately.

Modifications:

Added a HTTPServerPipelineHandler that only lets one request through
at a time.

Result:

Better servers that are more able to handle HTTP pipelining
2018-03-13 15:21:12 +00:00
Norman Maurer 005a3b702b Don't close ServerSocketChannel when accept fails with ECONNABORTED / EMFILE / ENFILE, ENOBUFS. ENOMEM. (#125)
Motivation:

We should not close the server socket when accept fails with ECONNABORTED / EMFILE / ENFILE, ENOBUFS. ENOMEM as generally speaking these may be "recoverable" once some existing connections were closed for example. It's possible to implement a backoff strategy for these with a ChannelHandler.

Modifications:

- Special handle of ECONNABORTED / EMFILE / ENFILE, ENOBUFS. ENOMEM for ServerSocketChannel.

Result:

Not close servet socket for errors from which it is possible to recover.
2018-03-13 15:09:13 +00:00
Cory Benfield e6456f9024 Add support for adding handlers at arbitrary pipeline locations (#128)
Motivation:

Currently we only supporting adding channel handlers at the front
or the end of the pipeline. This is potentially a bit frustrating:
it becomes impossible to insert handlers relative to a specific
point in the pipeline, which limits users ability to code generic
pipeline modification operations.

Modifications:

Added two new methods to ChannelPipeline, specifically
add(handler:before:) and add(handler:after:). Also performed a
substantial internal refactoring of the ChannelPipeline handler
adding code to ensure that all operations go through the same
logical path, redefining add(handler:first:) in terms of adding
either before tail or after head.

Result:

Users will be able to insert channel handlers at any point in a
ChannelPipeline, so long as they are able to point at a handler
already in that pipeline.
2018-03-12 20:16:13 +01:00
Cory Benfield fee84ed63a Revert "make isOpen a computed property (#123)" (#129)
This reverts commit 4deeaf6365.
2018-03-12 13:27:42 +01:00
Jason Toffaletti 4deeaf6365 make isOpen a computed property (#123)
Motivation:

Reduce memory footprint of BaseSocket and FileHandle

Modifications:

- made isOpen a computed var from 'descriptor >= 0'
- add withSocketpair to TestUtils
- use real pipe and socketpair file descriptors for tests
- BaseSocket and FileHandle init check precondition 'descriptor >= 0'

Result:

- isOpen no longer requires storage space
- close() sets descriptor to -1
- descriptor property changed from let to var
- tests will need to use valid file descriptors
2018-03-12 19:07:30 +09:00
Norman Maurer 95a6e44e93 Remove return when possible. (#122)
Motivation:

We can cleanup the code by removing return keywords in closures sometimes.

Modifications:

Remove return when possible.

Result:

Cleaner code.
2018-03-11 22:47:29 +09:00
Cory Benfield 43dd9c0b33 Ensure that handlers added with first:true are in proper order. (#118)
Motivation:

Right now addHandlers(first:) does not actually add handlers at the
front of the pipeline: it just adds them *backwards* at the end of
the pipeline. That's definitely not right.

Modifications:

Pass the first: flag into the call to add each specific handler to
ensure they're actually put at the front of the pipeline.

Result:

Handlers added to the front of the pipeline actually are.
2018-03-09 15:26:53 -08:00
Helge Heß ad8afee8aa Fix issue #110, IPv6 address desc contains 0 bytes (#111)
Motivation:

Fix for issue #110, .description on IPv6 addresses
return a String with 0 codepoints in it, like so:

  [IPv6]::1<NUL><NUL><NUL>....lots..

Modifications:

Use String(cString:) instead of decode, which doesn't
care about \0-cstr terminators.

Result:

Issue fixed, everything is awesome, everyone is happy.
2018-03-08 20:22:42 +09:00
Cory Benfield 1fdee500e5 Ensure channels don't get stuck completely unregistered. (#104)
Motivation:

It should be possible to have channels that are not registered
for any form of I/O without them getting stuck in that model
forever.

Modifications:

Remove the code that prevents channels registered for `.none` from
registering for anything else.

Result:

Channels can actually be registered for nothing without becoming
wedged open forever.
2018-03-06 02:08:19 +09:00
Johannes Weiß 94c21b6043 write/set(integer:) should like read/getInteger have an option as: argument so types can be specified (#82)
Motivation:

Sometimes getting read/getInteger to guess the type correctly can be
annoying and it's handy to just say `as: UInt8.self` or similar. In
other cases it's not as the type is clear from the environment. This now
enables both, just like we already have for `write/set(integer:)`

Modifications:

added an `as: T.Type = T.self` argument which is optional as it has a
default

Result:

easier to use `ByteBuffer` interfaces
2018-03-05 19:01:10 +09:00
Norman Maurer f3d3267977 Correctly update cached addresses for accepted Channels. (#98)
Motivation:

We missed to correctly update the cached remote and local addresses for accepted Channels. Because of this localAddress and remoteAddr always returned nil.

Modifications:

- Update cached addresses when constructing SocketChannel from existing Socket.
- Add testcase

Result:

Fixes [#97].
2018-03-05 18:44:14 +09:00
Cory Benfield 4afdf9d6ba Correctly validate delayed upgrade. (#92)
Motivation:

The previous delayed upgrade test didn't really validate what it
claimed to be doing: it validated properties of the I/O, which made
it enormously flaky.

Modifications:

Change the tests to check for the presence/absence of the server
upgrade handler, which is a mark of the actual upgrade process.

Result:

Less flaky tests
2018-03-03 14:41:27 -08:00
Cory Benfield f3f37af4ae Support enumerating network interfaces. (#47)
Motivation:

When writing programs that use networks, particularly if you want to
perform multicast joins, it's extremely important to be able to query
network interfaces and get results.

Modifications:

Add support for querying interfaces using getifaddrs and wrap those query
results in a Swift class.

Result:

Users will be able to enumerate the interfaces on their machine.
2018-03-03 09:04:57 +09:00
Ian Partridge 1167841b6f typo: ChannnelDuplexHandler should be ChannelDuplexHandler (#69) 2018-03-02 21:56:33 +09:00
Johannes Weiß 7402483b8d fix EventLoop-hopping thens (#51) (#63)
Motivation:

Previously if we'd futureOnEL1.then { ... in futureInEL2 } we'd forget
to hop from EL1 to EL2 which is bad. Shout out to @tanner0101 for
reporting!

Modifications:

Hop from one EventLoop to another if needed.

Result:

thens between Futures of different EventLoops now correctly switch
EventLoops.
2018-03-02 17:51:03 +09:00
adamnemecek 0bbed6d72f * removed trailing whitespace (#52) 2018-03-02 15:40:52 +09:00
Norman Maurer 613998ba9e
Add ChannelDuplexHandler protocol (#65)
Motivation:

Sometimes a user needs to implement ChannelInboundHandler and ChannelOutboundHandler. We should remove some of the "boilerplate" code for doing so.

Modifications:

- Add ChannelDuplexHandler and use it.

Result:

Less boilerplate code.
2018-03-02 14:52:42 +09:00
Cory Benfield f10840e297 Fix flaky upgrade test. (#45)
Motivation:

The upgrade test would race with itself and occasionally fail.

Modifications:

Give enough time for all the work to settle before closing the
client channel.

Result:

No more flaky tests.
2018-03-02 11:21:04 +09:00
Johannes Weiß b81ae9a4b0 fix zero capacity ByteBuffer reallocs (#44)
Motivation:

We'd go into an infinite loop when trying to increase the capacity of a
0 capacity ByteBuffer *doh*. Thanks @vlm for reporting and writing the
test.

Modifications:

made sure ensureAvailableCapacity returns at least 1 if we don't have
enough capacity available.

Result:

0 capacity ByteBuffers resize now.
2018-03-01 17:55:28 +09:00
Norman Maurer ee6cfcf9cf Add FileDescriptor protocol and implement it for FileHandle / BaseSocket (#38)
Motivation:

FileHandle and BaseSocket should implement a common protocol as these are both "based" on file descriptors

Modifications:

- Add FileDescriptor protocol
- Implement it for FileHandler and BaseSocket

Result:

Better code structure
2018-02-28 09:46:29 +00:00
Norman Maurer d2bd75328b
Fix test code on linux (#37)
Motivation:

73a805c7f6 did some changes but missed to rename one variable. This broke the build on linux.

Modifications:

Rename fn to body.

Result:

Builds again on linux.
2018-02-27 07:36:23 +09:00
Johannes Weiß 73a805c7f6 minor stylistic improvements (#36)
Motivation:

Sometimes we deviated from the style the Swift stdlib sets out for no
reason.

Modifications:

Fixed some stylistic deviations.

Result:

Looks more Swift-like.
2018-02-26 15:52:49 +00:00
Norman Maurer 0797b5c293 EmbeddedChannel should call fireChannelRegistered(...) when register(...) is called. (#34)
Motivation:

At the moment EmbeddedChannel calls fireChannelRegistered() when connect(...) is called. This is not correct, as it should be done when register(...) is called.

Modifications:

- Correctly call `fireChannelRegistered(...)` when register(...) is called
- Simplify init of EmbeddedChannel
- Fix EmbeddedChannelTest

Result:

Correct invocation of methods.
2018-02-26 10:57:07 +00:00
Norman Maurer 02c573a505 Fix ChannelLifecycleHandler lifecycle recording (#33)
Motivation:

ChannelLifecycleHandler should record .registered as lifecycle in channelRegistered and not .inactive

Modification:

- Correct record .registered
- Fix tests

Result:

Correctly record lifecycle state.
2018-02-26 09:52:39 +00:00
Cory Benfield a779d2f084 Remove the promise-handling from the PWM. (#25)
Motivation:

We no longer have flush promises, so the PWM no longer needs to
handle them.

Modifications:

Removed all flush promise handling from the PWM and associated
tests.

Result:

Less code, more clarity.
2018-02-23 13:13:50 +01:00
Cory Benfield 369a0714ae Remove management of flush promises from PDWM. (#24)
Motivation:

A substantial chunk of code complexity exists in the PDWM to manage
flush promises. This complexity is no longer justified now that we
don't bother with them.

Modifications:

Removed much of the complexity of the PDWM handling of flush promises.

Result:

Simpler, easier to understand code.
2018-02-23 13:09:00 +01:00
Norman Maurer c95051db78 Make WriteBufferWaterMark be a struct and validate low and high watermarks. (#21)
Motivation:

We used Range for WriteBufferWaterMark which did not do any validation of the low and high marks.

Modifications:

Make WriteBufferWaterMark a struct and validate low and high values

Result:

More correct impl for watermarks.
2018-02-23 09:52:30 +00:00
Cory Benfield 95c00129ee
Correctly update remote peer address on delayed connect. (#18)
Motivation:

When the connect() call does not complete synchronously we were not
updating the peer IP address when it finally did complete. This meant
that any channel that didn't connect synchronously (in the real world,
almost all of them) would not correctly see the remote peer IP.

Modifications:

Update the cached addresses on delayed connect.

Result:

Connected channels will see the correct remote IP.
2018-02-22 17:47:56 +00:00
Cory Benfield 2a3396998d HTTPUpgradeHandler should accept Futures for upgraders. (#10)
Motivation:

Currently the HTTPUpgradeHandler does not allow for the protocol
upgraders to return EventLoopFuture objects. This leads to an
awkward scenario: it's essentially required that an upgrader be able
to synchronously change the pipeline to its satisfaction and prepare for
more bytes.

This is not really possible: ChannelPipeline.add(handler:) returns a
Future, which means that it is possible for this operation, at least
in principle, to not execute synchronously. This reality puts the
HTTPUpgradeHandler at odds with the reality of channel pipelines, and
cannot stand.

Modifications:

Give the HTTPProtocolUpgrader protocol to have upgrade() return an
EventLoopFuture<Void>, and update the HTTPServerUpgradeHandler to
appropriately handle the returned future by buffering until the future
completes.

Result:

It is no longer necessary to synchronously change the channel
pipeline during protocol upgrade.
2018-02-22 14:03:26 +01:00
Cory Benfield 088c09ece5 Improve Linux test gen script to match current format. (#3)
Motivation:

Right now the test gen script will rewrite every file. Not ideal!

Modifications:

Added the license header, and made the follow-on comment match that
style.

Result:

Test files will look the same when running this script as they do
now.
2018-02-21 20:16:28 +01:00
Cory Benfield c8c8dbf2a2 Don't require casing to match in the HTTP upgrade header. (#1)
Motivation:

The HTTP upgrade handler should not require that we case-match with
the mandatory headers.

Modifications:

Treat all headers as lowercase.

Result:

Upgrade is easier.
2018-02-21 20:15:12 +01:00
Johannes Weiss 5deffc630d replace `var closed` with `var isOpen` for more positive conditions
Motivation:

guard !self.open else { ... } is a double negation and can be confusing,
guard self.isOpen else { ... } is much better

Modifications:

replaced all `var closed: Bool` with `var isOpen: Bool`

Result:

we're more positive
2018-02-21 15:09:22 +00:00
Norman Maurer adbcd7c4a8 Make half-closure tests more robust.
Motivation:

Out half-closure tests did not wait for the actual event to be received before trying to tear-down the Channel which could lead to test-failures if the event was received not fast enough. We need to ensure we wait until we receive the event before closing the Channel and assert the received events.

Modifications:

Ensure we wait for the events before we try to close the Channel and assert the received events.

Result:

Less flaky tests.
2018-02-21 10:53:52 +01:00
Johannes Weiß 2e5f62d653 make ByteBuffer.set/write work on Sequence rather than Collection
Motivation:

Previously we required the `ByteBuffer.set/write` methods to be a
`Collection` of `UInt8` but a `Sequence` is really enough.

Modifications:

Implemented `ByteBuffer.write/set` for `Sequence`s of `UInt8`

Result:

More stuff can be used with `ByteBuffer`
2018-02-20 16:37:39 +00:00
Johannes Weiss c7e47e75f3 remove flush promises
Motivation:

We have multiple reasons why flush promises weren't great, for example:

- writeAndFlush sounds like it's a write + flush optimisation but in
  reality it was more expensive (2 extra promises)
- the semantics were never quite clear
- lots of implementation complexity, especially for the datagram channel

Modifications:

- removed the flush promises in the API
- this deliberately doesn't do the PendingWritesManager simplifications
  that this unlocks

Result:

flush doesn't have a promise anymore.
2018-02-20 16:13:41 +00:00
Johannes Weiß 64eac6177c make inbound channel operations non-throwing
Motivation:

Except for blocking methods (which shouldn't be used on the event loop),
there aren't that many error cases that we should just send through the
pipeline automatically. Best proof for that is that nothing in the code
base did that. Therefore these methods shouldn't be throwing.

If the user does indeed want to catch and fire an error through the
pipeline that's still super simple `ctx.fireErrorCaught(error)`.

Modifications:

removed `throws` from the `ChannelInboundHandler` methods.

Result:

better
2018-02-19 18:10:21 +00:00
Cory Benfield 58e147f682 ByteToMessageDecoder should reclaim memory.
Motivation:

ByteToMessageDecoder implementations can potentially have usage
patterns that never reclaim memory. This is problematic when used
for a long time, as they can be holding on to large chunks of memory
they don't need.

Modifications:

Gave ByteToMessageDecoder a new protocol method,
shouldReclaimBytes(buffer:), and a default implementation.

Result:

ByteToMessageDecoders will not be able to hold on to more than 2kB
of unreachable memory under any circumstances, and will often hold
less memory than that.
2018-02-20 14:12:20 +00:00
Norman Maurer 6e9b626d57 We should not use deprecated methods.
Motivation:

We had some usage of deprecated methods.

Modifications:

Replace deprecated method usage.

Result:

No more warnings during build.
2018-02-20 16:21:04 +01:00
Johannes Weiss 68724be6e6 fix Channel thread-safety (local/remoteAddress)
Motivation:

There were a couple of places in the Channel implementations that just
weren't thread-safe at all, namely:

- localAddress
- remoetAddress
- parent

those are now fixed. I also re-ordered the code so it should be easier
to maintain in the future (the `// MARK` markers were totally
incorrect).

Modifications:

- made Channel.{local,remote}Address return a future
- made Channel.parent a `let`
- unified more of `SocketChannel` and `DatagramSocketChannel`
- fixed the `// MARK`s by reordering code
- annotated methods/properties that are in the Channel API and need to
be thread-safe

Result:

slightly more thread-safety :)
2018-02-20 15:18:51 +00:00
Norman Maurer 273932ae36 Change ByteToMessageDecoder.decode and decodeLast to return an enum.
Motivation:

We used a bool to signal if we should continue decoding or not. Using an enum is more self-documenting.

Modifications:

Add DecodingState and use.

Result:

Code is more self-documenting.
2018-02-20 13:07:31 +01:00
Cory Benfield 6b999ad368 Remove quadratic buffering from ByteToMessageDecoder
Motivation:

Don't make the system fall over under slowloris-style attacks.

Modifications:

Remove the quadratic copy loop from ByteToMessageDecoder.

Result:

NIO goes from 🚂 to 🚄
2018-02-20 08:02:43 +00:00
Norman Maurer 1912948fd4 Remove promise parameter on read method.
Motivation:

The promise on read is not very useful, we should just remove it.

Modifications:

Remove promise.

Result:

Cleaner code.
2018-02-19 21:39:46 +01:00
Johannes Weiss 26582a3e97 redundant let elimination
Motivation:

`let _ = ...` is redundant and should be `_ =`

Modifications:

removed redundant `let`s

Result:

saved disk space ;)
2018-02-19 17:41:52 +00:00
Johannes Weiss 225951e7c3 remove Foundation dependency
Motivation:

Foundation is problematic for a few reasons:
- its implementation is different on Linux and on macOS which means our
  macOS tests might be inaccurate
- on macOS it uses ObjC Foundation which means the autorelease pool
  might get populated
- it links the world on Linux which means we can't do static
  binaries at all

Modifications:

removed the last bits of Foundation dependency

Result:

no Foundation dependency
2018-02-19 17:22:38 +00:00
Johannes Weiss ca6b0ff28d replace Foundation whitespace trimming
Motivation:

For HTTP parsing, we used Foundation to trim whitespace which is not
needed.

Modifications:

Implemented whitespace trimming in Swift.

Result:

less Foundation
2018-02-19 12:55:29 +00:00
Johannes Weiss 4a09182a39 rewrite closures that just ignore their parameter & change whenComplete
to not return a value

Motivation:

We recently had a bug where we had `EventLoopFuture<EventLoopFuture<()>>` which didn't make any sense. The compiler couldn't catch that problem because we just ignored a closure's argument like this:

    future.then { _ in
        ...
    }

which is dangerous. For closures that take an empty tuple, the `_ in`
isn't actually required and the others should state the type they want
to ignore.

And most whenComplete calls can be better (and often shorter) expressed
by other combinators.

Modifications:

remove pretty much all closures which just blanket ignore their
parameter.

Result:

- no closures which just ignore their parameter without at least stating
  its type.
- rewrote all whenCompletes that actually used the value
2018-02-16 17:28:43 +00:00
Norman Maurer eb98b651bb Cleanup test code
Motivation:

We had a few return statements that could be removed and some places where trailing closure syntax could be used.

Modifications:

- Remove returns
- Use trailing closures

Result:

Cleaner code.
2018-02-16 15:22:18 +01:00
Norman Maurer 55e99b603d Expose BlockingIOThreadPool
* Expose BlockingIOThreadPool

Motivation:

Sometimes we need to execute some blocking IO. For this we should expose the BlockingIOThreadPool that can be used.

Modifications:

- Factor out BlockingIOThreadPool
- Added tests
- Correctly start threadpool before execute NonBlockingIO tests.

Result:

Possible to do blocking IO.

* Corrys comment

* Correctly start pool before using it
2018-02-16 14:53:19 +01:00
Cory Benfield ab9427bdd4 Initial UDP support 2018-01-16 17:00:09 +00:00
Johannes Weiss 0e7b90ef16 unify channel write handling for stream and datagram channels
Motivation:

After the previous change to the channel writes, the datagram and the
stream PWMs behaved differently and there was code duplication.

Modifications:

Removed different behaviour & reduced code duplication

Result:

Less code and hopefully less bugs.
2018-02-16 09:19:52 +00:00
Johannes Weiss be1de1c433 simplify channel writes
Motivation:

Channel writes are a complex matter and it was even more
complex when `FileRegion` and `ByteBuffer` were completely
different kinds of objects. Now that they're more in line we can
simplify a lot of things.

Modifications:

Rewrote the inner layers of channel writes to make them more readable
and hopefully more correct.

Result:

hopefully fewer bugs.
2018-02-15 14:07:57 +00:00
Johannes Weiß 5cb13b21e6 make FileRegion a value type and behave much more like ByteBuffer
Motivation:

Previously `FileRegion` was a special snow flake, a bit like
`ByteBuffer` but also totally different. That caused surprise and made
`PendingWritesManager` even harder. It was also used to manage the
lifetime of a file descriptor but only sort of.

Modifications:

We now have a `FileHandle` which is a one-to-one mapping with a file
descriptor and its lifetime must be managed appropriately.

Result:

hopefully less bugs and fd leaks.
2018-02-06 16:48:35 +00:00
Cory Benfield 67bb71e44b Add a pending datagram writes manager
This change adds support for doing datagram-style writes. It's not currently
hooked up to anything, but it will be sometime soon.
2018-02-14 15:32:31 +00:00
Johannes Weiss eaa8ffaee4 remove redundant labels
Motivation:

Lots of our most important operations had redundant labels like

    func write(data: NIOAny)

the `data: ` label doesn't add anything meaningful and therefore it
should be removed.

Modifications:

removed lots of redundant labels

Result:

less redundant labels
2018-02-13 11:13:30 +00:00
Johannes Weiß dba0a5379c fix longstanding typo in newSucceededFuture
Motivation:

We used to have a method `newSucceedFuture` which should be
`newSucceededFuture`

Modifications:

grammar

Result:

better grammar
2018-02-13 09:55:33 +00:00
Johannes Weiß 2c95f53e0f fix master build
Motivation:

master didn't build

Modifications:

fixed it

Result:

works again
2018-02-12 18:51:26 +00:00
Johannes Weiß 85b45e6912 make function names for connect/bind/SocketAddress more Swift-like 2018-02-12 15:09:22 +00:00
Norman Maurer 5aff263ad9 Correctly handle ChannelError.eof when reading data from Socket
Motivation:

The code to filter out ChannelError.eof when reading from the socket and not call fireErrorCaught(...) was broken and so the error was propagated through the pipeline.

Modifications:

- Correctly filter out .eof
- Added testcase

Result:

Correct handling of .eof
2018-02-12 16:50:34 +01:00
Norman Maurer 18a8467dfe Make parameter naming between connect / bind consistent.
Motivation:

We should have consistent parameter naming.

Modifications:

Use to path: everywhere.

Result:

Consistent naming.
2018-02-12 14:21:07 +01:00
Johannes Weiß 1d7302a189 make future map not allocate if the values are () 2018-02-12 12:46:49 +00:00
Johannes Weiss 01c6e175b7 improve FileRegion tests 2018-02-12 11:52:55 +00:00
Norman Maurer b09c1598af Fix testcase which was not correctly updated as part of 845d9ee8e95e8ba61e550a26b0a70d59ee98c97d 2018-02-12 08:39:38 +01:00
Johannes Weiß 11a609396d don't blow up when holding onto a ChannelPipeline of a deinitialised Channel 2018-02-09 14:53:09 +00:00
Johannes Weiß ebf351abda implement thread specific values 2018-02-08 17:37:01 +00:00
Cory Benfield 3f357a3c79 Minor cleanups for Swift 4.1 2018-02-08 11:40:45 +00:00
Johannes Weiss 734904d0f4 clean up the (proto)types for EventLoopFuture
* clean up the (proto)types for EventLoopFuture

* Remove more unnecessary parens
2018-02-09 16:03:28 +00:00
Daniel Dunbar 41bf7278f8 [NIO] Fix setOption() to be async.
- This fixes Bootstrap's ChannelOptionStore.applyAll to return a future rather
   than synchronously iterating through all the options.

 - This is particular important because when a server accepts a child, if the
   child channel is on a different event loop then it is possible the
   synchronous calls may deadlock (if the child's eventloop happens to be
   scheduled with a similar accept sequence).

 - I did not tackle also making getOption() async, which means the Channel API
   is asymmetric at the moment. That should probably be addressed, potentialy
   with synchronous wrappers for API compatibility.

 - Fixes: <rdar://problem/37191923> [Omega] Worker tasks fail to close subtasks (many connections in CLOSE_WAIT state)
2018-02-08 09:21:40 -08:00
Norman Maurer 995177fbc6 Support setting Thread affinity and use it with EventLoopGroups 2018-02-06 16:08:57 +01:00
Cory Benfield ce7b0c52ce Add a CompositeError type 2018-02-08 13:12:30 +00:00
Cory Benfield 08817ded87 Remove copy in withMutableSockAddr 2018-02-08 12:52:03 +00:00
Cory Benfield 453b87ff5e Fixup thread unsafety 2018-02-08 10:57:46 +00:00
Cory Benfield 3768e2a2b9 Don't allow registration on shutting down loops 2018-02-08 10:25:47 +00:00
Johannes Weiss 755ea5aedc non-blocking file IO 2018-02-07 17:25:45 +00:00
Johannes Weiss e21432e955 don't leak open FileRegions (fds) in HTTP client 2018-02-06 16:35:35 +00:00
Johannes Weiß 9c73c9deb9 fix flaky ChannelTests.testHalfClosure 2018-02-06 15:24:01 +00:00
Daniel Dunbar 74a10d8137 [SocketAddress] Add .port accessor.
- This is for convenience in clients which want to get the assigned port, when
   OS-assigned ports are used.
2018-02-05 12:42:57 -08:00
Cory Benfield 2630d583cd Happy Eyeballs! 2018-02-02 17:26:51 +00:00
Cory Benfield 1ae2c97903 Make SocketAddress equatable 2018-02-02 10:28:11 +00:00
Cory Benfield b3ed4eee1b Preparatory refactor of PWM for datagrams 2018-01-31 16:21:13 +00:00
Cory Benfield 5ce3ac2142 Add socket address helpers 2018-01-31 15:43:45 +00:00
Johannes Weiss ce1d4bb7d8 fix ByteBuffer docs of withUnsafeWritableBytes 2018-01-31 14:15:22 +00:00
Max (Swift) Moiseev 973a96004d Get rid of free functions
* Lift the EventLoopFuture.== into the type extension and add the Equatable conformance

* Get rid of the only public free function systemCoreCount
2018-01-30 10:41:44 -08:00
Johannes Weiss eab7d314f3 make Channel non optional in ChannelHandlerContext 2018-01-30 12:03:51 +00:00
Johannes Weiss af4dabb0fa rename the Future's functor map function to map 2018-01-30 08:25:20 +00:00
Johannes Weiss b3799b9403 take OpenSSL support out of tree 2018-01-26 09:50:38 +00:00
Cory Benfield 1fffa95ad1 Make ChannelCore writes use NIOAny 2018-01-25 12:12:02 +00:00
Johannes Weiss 4a2425f5b7 promise leak debugging 2018-01-24 08:21:35 +00:00
Cory Benfield 92634a68fb Add utility for detecting core count. 2018-01-22 12:05:43 +00:00
Cory Benfield 34cc404142 Refactor internal storage model for SocketAddress 2018-01-22 12:07:40 +00:00
Cory Benfield 9908b391db Prevent SniHandler wrongly calculating packet length. 2018-01-19 16:39:46 +00:00
Johannes Weiss 7d5109a673 no auto headers for GET 2018-01-19 15:46:52 +00:00
Johannes Weiss 24abe7fe19 merge (& fix) the inbound and outbound channel pipelines 2018-01-19 14:50:37 +00:00
Johannes Weiss db28cf4452 don't pretend user events are typed & remove tryUnwrap for in/outbound data 2018-01-19 14:12:57 +00:00
Norman Maurer 4d8cf1ff22 Add support for closing only the output / input side of the Channel. 2017-12-28 13:40:31 +01:00
Cory Benfield 1535c2f5fc Add IP string parsing 2018-01-18 18:07:50 +00:00
Norman Maurer 2e2a82b27e Try to drain inbound data on write error.
Motivation:

To ensure we not leave any unread data on the socket we should try to read one last time (if autoread is enabled).

Modifications:

- Depending on if autoread is enabled or not we will try to read one more time
- Guard against re-entry of flushNow0()
- Correctly handle SIGPIPE in all cases
- Add testcase

Result:

Drain data from socket on write error if needed.
2017-12-27 08:10:53 +01:00
Johannes Weiss 8b74d21562 more robust tempfiles for SSL trust bundle 2018-01-10 17:19:02 +00:00
Johannes Weiß c79c5ba364 re-export Darwin/Glibc and reduce number of #if os(...) 2018-01-09 15:08:17 +00:00
Johannes Weiss b9a982bfa1 improve robustness of SSL/TLS tests regarding errors thrown
previously on some errors we'd leak a promise without a good way to
debug. This should shed some light on that.
2018-01-09 14:27:32 +00:00
Cory Benfield 9fd4006c93 Add explicit time control to EmbeddedEventLoop 2018-01-08 17:59:18 +00:00
Johannes Weiss 64ef7728f9 finish renaming ByteBuffer getters to getType 2018-01-09 09:32:39 +00:00
Johannes Weiß 5f21764710 fix compiler warning & typo 2018-01-08 16:48:44 +00:00
Cory Benfield 8ee527ac52 Simplify running code 2018-01-08 16:39:54 +00:00
Johannes Weiss 9a5390495e improve channel pipeline
We now use two (doubly) linked lists (inbound & outbound) for the
ChannelPipeline. Previously we used two singly linked lists and an
array. That would give us the worst of the two worlds: Linear time
modifications and complicated code.
2018-01-05 18:17:34 +00:00
Johannes Weiss 8674154403 remove pretty much all try!s from the tests 2018-01-05 16:22:38 +00:00
Johannes Weiss d2b671da66 make HTTPServerClientTests more robust 2018-01-05 15:19:22 +00:00
Johannes Weiss 62b4acaedf ByteBuffer.clear: Prevent copying bytes if allocation is necessary 2018-01-05 15:01:48 +00:00
Johannes Weiss e217dea875 fix EmbeddedChannel: created more than one EmbeddedEventLoop 2018-01-04 18:08:07 +00:00
Johannes Weiss 03a299795f make the test*Blast() tests not crash but fail if ChannelPipeline doesn't work 2018-01-04 15:53:07 +00:00
Norman Maurer 43303437d1 Declare option label as optional in ClientBootstrap 2017-12-21 22:04:42 +01:00
Norman Maurer 8b9a31536e Allow to specify a connect timeout 2017-12-20 15:26:39 +01:00
Norman Maurer 8f1ad37edd Use camel case for ChannelOption factory values and add docs 2017-12-20 14:18:07 +01:00
Johannes Weiss dfd25bf576 refactor Channel initialisation & *Bootstrap docs 2017-12-13 15:42:54 +00:00
Johannes Weiß d7d1d5dbf5 fixed a near miss (thanks Swift 4.1 compiler warning) 2017-12-18 15:57:31 +00:00
Johannes Weiß 94e1af5452 compile warning-free on Swift 4.1 2017-12-18 15:37:57 +00:00
Johannes Weiss fa35c603a0 on Darwin, sendfile might write fully and return EWOULDBLOCK 2017-12-15 16:58:12 +00:00
Cory Benfield 0fa0224623 Configure this pipeline properly 2017-12-15 12:29:28 +00:00
Norman Maurer 76482816e6 Prefix all ByteBuffer methods with `get` if these allow access to unitialized memory. 2017-12-15 12:24:09 +01:00
Cory Benfield 3614d09a4b Provide a nicer setup helper for HTTP connections 2017-12-13 15:38:40 +00:00
Cory Benfield 4154a3bcbc Don't shut connections aggressively in tests 2017-12-15 10:41:46 +00:00
Cory Benfield f3e72c13f3 Add HTTP streaming compressor 2017-12-15 09:50:12 +00:00
Cory Benfield bcdef57481 Correctly track the writer index 2017-12-15 08:24:38 +00:00
Cory Benfield be3d8d00f8 Correctly decode HTTP HEAD responses 2017-12-13 17:10:44 +00:00
Johannes Weiss 8a1297eff1 Channel docs 2017-12-13 16:07:14 +00:00
Johannes Weiss e60ef7fdc8 trivial: fix unused result warning in tests 2017-12-13 11:50:16 +00:00
Cory Benfield 07f5eb95e2 Enforce promise ordering for zero length writes 2017-12-12 16:38:31 +00:00
Cory Benfield 9b9caa1d20 Don't explode on zero-length writes 2017-12-12 16:04:21 +00:00
Johannes Weiss e4ef4c19f7 fix write spinning (should be max `writeSpinCount` writes) 2017-12-12 14:14:10 +00:00
Johannes Weiss 4e188e74b3 Channel tests: use canary value to make sure we don't write past buffer end for iovecs 2017-12-12 13:26:28 +00:00
Johannes Weiss 59566c6365 Channel writes: Tighter asserts & now 100% test coverage 2017-12-12 12:57:45 +00:00
Johannes Weiss 69c0cd463b fix random typos 2017-12-12 11:37:07 +00:00
Cory Benfield 2373863f54 No fatal error on unexpected non-ciphertext data 2017-12-12 11:31:05 +00:00
Johannes Weiß 25f4e2ceff PriorityQueue: make it work for partial orders 2017-12-12 11:13:33 +00:00
Cory Benfield 584fdb6507 ByteToMessageDecoder must propagate ChannelInactive 2017-12-12 10:49:12 +00:00
Johannes Weiss b203c602a9 Channel writes: more bugs found & fixed 2017-12-12 08:05:57 +00:00
Johannes Weiss 40454741d1 more interesting PriorityQueue test 2017-12-11 14:34:49 +00:00
Cory Benfield ba183774f6 Don't assert clean shutdown 2017-12-11 13:13:15 +00:00
Johannes Weiss 64a1c2feb8 Channel writes: unit tests & lots of fixes 2017-12-11 12:20:46 +00:00
Johannes Weiss 8a4a658bc7 fix large ByteBuffer allocations 2017-12-08 10:37:14 +00:00
Johannes Weiss b579f80efd in failAll we double accounted for outstanding ByteBuffers :( 2017-12-08 09:40:31 +00:00
Johannes Weiß e1b30f0a3d fix Channel writes 2017-12-05 17:08:42 +00:00
Johannes Weiss 215620d7a6 syscall wrapper: don't do an allocation for every failed syscall 2017-12-07 15:37:12 +00:00
Norman Maurer 7379be49f5 Replace mktemp usage with mkstemp to silence warnings when running tests.
Before this was printed out.

NIOOpenSSLTests/SSLCertificateTest.swift:105: warning: the use of `mktemp' is dangerous, better use `mkstemp' or `mkdtemp'
2017-12-04 18:48:49 +01:00
Johannes Weiss ff991da658 make the CircularBuffer implementation more straightforward & docs 2017-12-04 16:59:16 +00:00
Norman Maurer 1a9cd14118 More agressively try to increase the number of bytes we read from the Channel per read.
Motiviation:

We used to only allocate one buffer per read loop (by default we use multiple reads per loop) and record for the next loop iteration if we need to allocate a bigger buffer or not. This can lead to very slowely ramping up of number of bytes we read. We should better detect if we should allocate a new buffer because we used all the writable bytes to allow faster ramping up of numbre of bytes to read .

Modification:

- Change RecvByteBufferAllocator.record to return a Bool that wil lsignal if we used all the writable bytes of the last allocation and so may want to try to allocate a bigger buffer again
- Adjust tests.

Result:

Faster adjustment of the ByteBuffer capacity when reading data.
2017-12-04 15:43:13 +01:00
Johannes Weiss 5eca60e46b make ByteBuffer tests slightly more interesting 2017-12-01 17:39:23 +00:00
Johannes Weiss 98017432b8 dont require Foundation for IOError description creation 2017-12-01 14:31:37 +00:00
Johannes Weiß a22fc02c51 ByteBuffer: fix a UInt underflow 2017-11-30 16:57:26 +00:00
Johannes Weiss 8335b6c3a0 replace priority queue 2017-11-28 16:13:26 +00:00
Cory Benfield 2cfa8c2381 Remove use of URL and FileManager from NIOOpenSSL 2017-11-23 10:11:38 +00:00
Cory Benfield 99188f3a99 Don't lose close promises 2017-11-21 19:00:36 +00:00
Johannes Weiß 06f9b1d63b merge ConcurrencyHelpers 2017-11-21 18:32:33 +00:00
Johannes Weiß 33fe401322 rename Future/Promise to EventLoopFuture/EventLoopPromise 2017-11-21 17:41:36 +00:00
Johannes Weiss 4a74aca592 integration test for syscall wrapper 2017-11-21 15:00:25 +00:00
Johannes Weiß 202e1c37d7 port integration tests for HTTP server 2017-10-10 19:41:01 +01:00
Cory Benfield 229c23a63b Support X.509 hostname validation 2017-11-20 14:26:22 +00:00
Johannes Weiss 09b8925591 make ChannelHandlerCtx operations not crash if channel is already closed 2017-11-17 14:57:25 +00:00
Johannes Weiß 936e812b32 make system call wrapper fast & test it 2017-11-16 15:42:03 +00:00
Norman Maurer f369a17d42 Fix warnings that are cased by using try for functions that not throw. Leftover from 4a315c9e9d12345e70b838cdfea54ddb0b191da8 2017-11-16 19:39:16 +01:00
Cory Benfield 1cb736e370 Catch bugs with sync shutdown 2017-11-10 17:28:52 +00:00
Cory Benfield 4cf0bbaaf4 Make our circular buffers collections 2017-11-16 12:56:29 +00:00
Johannes Weiß 31cd14eaad fix inEventLoop race and makes TSan happy 2017-11-10 14:56:33 -08:00
Cory Benfield 8ff2d5bb92 OpenSSL ALPN support 2017-11-13 12:45:57 +00:00
Cory Benfield 8d2f13be68 Add parent property 2017-11-13 10:11:52 +00:00
Johannes Weiss f6343496c3 add another test for a very large number of buffered writes 2017-11-11 00:10:23 -08:00
Cory Benfield be81dbacff Forbid oversized writev calls 2017-11-10 16:08:49 +00:00
Cory Benfield 13d80285c8 Don't write too much to writev 2017-11-10 15:45:41 +00:00
Johannes Weiß 40edb34d8f introduce & test ByteBuffer.readString 2017-11-08 13:06:09 -08:00
Cory Benfield e72569e329 Add client-side SNI support 2017-10-25 15:04:46 +01:00
Cory Benfield 8efedf33fa Add ALPN handler 2017-11-01 16:14:11 +00:00
Norman Maurer 976f4752df Add HTTPRequestEncoder / HTTPResponseDecoder implementation and tests 2017-11-02 13:50:46 +01:00
Johannes Weiss c18db56fc2 make >= 0 checks for index/length a precondition 2017-11-09 02:49:11 -08:00
Max Moiseev dccbbf0bb7 Remove unnecessary Numeric constraint 2017-11-08 14:46:10 -08:00
Johannes Weiß 20800ed454 use the now fully featured FixedWidthInteger instead of EndiannessInteger 2017-11-08 13:08:02 -08:00
Cory Benfield 4d09289f9b Add missing test 2017-11-08 14:33:57 +00:00
Norman Maurer 9bb7f6727d Use correct types in default method
Motivation:

The default method we added for the MessageToByteEncoder has the incorrect parameter types and so is useless.

Modifications:

Fix type of parameter.

Result:

Default method match the protocol requirement.
2017-11-08 01:14:43 -08:00
Cory Benfield 7a7536d076 Add support for X.509 subject commonName. 2017-11-03 13:49:32 +00:00
Johannes Weiss 839a5050dd ByteBuffer: fast path for contiguous collections 2017-11-03 02:39:54 -07:00
Norman Maurer c22e5ead6b Remove ByteBufferAllocator constructor argument from HttpResponseEncoder
Motivation:

We can allocate the buffer on the fly if needed, no need to add the constructor argument.

Modifications:

Just allocate the buffer in the methods itself that need it.

Result:

Easier to construct encoder and cleaner code.
2017-11-02 12:56:00 +01:00
Cory Benfield 4e04a275c0 Add internal support for subjectAltName 2017-11-01 17:46:56 +00:00
Cory Benfield cffd11d4e8 Fix tests that do not expect IOData 2017-11-01 16:24:59 +00:00
Cory Benfield 6d8848d239 Omit chunked encoding for HTTP/1.0 2017-11-01 16:17:23 +00:00
Norman Maurer 22a35b2bdb Add FileRegion support when using HTTP
Motivation:

Often people want to transfer large files over http which should be done using sendfile(...) for best performance.

Modifications:

- Add support for using FileRegion when sending body parts.
- Add tests

Result:

Be able to serve files without loading these into memory
2017-11-01 16:02:14 +01:00
Cory Benfield 8f2d17bc55 Break out common TLS events 2017-11-01 10:56:15 +00:00
Norman Maurer a172546d7b Use typesafe ChannelInboundHandler in IdleStateHandlerTest 2017-10-30 16:40:31 +01:00
Cory Benfield 8b860d3009 Add SNI handler 2017-10-30 10:58:26 +00:00
Norman Maurer 9c7829a065 Port IdleStateHandler from Netty 2017-10-29 09:46:48 +01:00
Johannes Weiß 6173bee782 Split IOData into NIOAny & IOData (ByteBuffer | FileRegion) 2017-10-25 19:31:27 +01:00
Cory Benfield 32c30074ea Split client/server processing in OpenSSL 2017-10-24 16:41:23 +01:00
Johannes Weiss e9c76088ac ByteBuffer: avoid potential overflows for reading functions 2017-10-24 13:24:47 +01:00
Cory Benfield 25d57e8fab Add Channel.isActive 2017-10-19 16:44:42 -07:00
Cory Benfield b2cbe766f0 Add support for HTTP Upgrade 2017-10-12 17:24:00 -07:00
Johannes Weiss cf352ac0c3 depend on OpenSSL properly 2017-10-19 19:51:42 +01:00
Cory Benfield fb9e14b4d4 Don't lose promises on synchronous close. 2017-10-18 16:53:45 -07:00
Cory Benfield 7dddd67608 Add TLS configuration object 2017-09-29 14:25:46 +01:00
Tom Doron f76a2bfa66 sort linux tests
motivation: generated linux tests dont have consitent sorting in different OSs

changes:

* change test generator to sort tests and imports in memory before writing to file
* update LinuxMain to the sorted version
2017-10-17 09:51:59 -07:00
Johannes Weiss 2889c7e3de fix buffer confusion on incomplete writes 2017-10-17 16:51:15 +01:00
Cory Benfield 0803012b7a Add support for retrieving headers in canonical form 2017-10-13 14:13:45 -07:00
Cory Benfield 2a7066873a Add missing Linux tests 2017-10-13 15:02:22 -07:00
Cory Benfield 6f17b320d5 Ensure no transfer-encoding when body is forbidden 2017-10-13 13:44:51 -07:00
Johannes Weiss 3bef8a4012 turn `import Foundation` comments into code :) 2017-10-12 16:33:50 +01:00
Cory Benfield 1f52bac1f9 Add support for HTTP trailers 2017-10-04 13:49:03 +01:00
Cory Benfield 8094e43582 Prevent multiple closure of the EmbeddedChannel. 2017-10-10 09:21:46 -07:00
Johannes Weiss 0b265368a1 use the new Swift 4 String APIs for encoding/decoding Strings 2017-10-10 17:12:02 +01:00
Johannes Weiss 1adb581f59 remove more Foundation imports 2017-10-10 16:25:43 +01:00
Cory Benfield 47ac46bbe3 Don't join Set-Cookie headers together 2017-10-09 10:37:13 -07:00
Cory Benfield 3b40563a5e Prevent hot loop starving I/O 2017-10-09 18:14:49 -07:00
Cory Benfield c2f461e4b7 [OpenSSLHandler] Flush less frequently for outgoing application data. 2017-10-04 17:29:38 +01:00
Cory Benfield 55ae8a8606 Make MarkedCircularBuffer public 2017-10-02 11:36:29 +01:00
Johannes Weiss de2cb8a038 ByteBuffer.set with Collection of UInt8 2017-09-29 15:41:32 +01:00
Johannes Weiss b735ddf306 HTTPServerClientTest: depend on channelReadComplete working 2017-09-29 14:58:33 +01:00
Cory Benfield e2722732b7 Allow write during channelActive.
* Test that we can write during channelActive

* Flush after connect complete
2017-09-27 16:46:15 +01:00
Cory Benfield 35dd5fce48 Flush immediately without pending writes.
* Add failing test for flush on empty

* Succeed flushes immediately when possible
2017-09-27 16:24:43 +01:00
Cory Benfield bdce6b39ca Better handle multiple calls to close() in TLS. 2017-09-27 11:16:58 +01:00
Cory Benfield 8a6d9c825c OpenSSL-based TLS support
Add initial OpenSSL support to NIO.
2017-09-26 14:47:41 +01:00
Johannes Weiss a73d46f218 HTTP/1.1 Chunked Encoding
* HTTP/1.1 Chunked Encoding

* fix MarkedCircularBuffer: if not marked do not try to move mark when removing first

* fix HTTPRequestDecoder: dispatch callouts after parsing is complete

* fix HTTPTest: feed pipeline the inbound data correctly
2017-09-25 15:33:02 +01:00
Johannes Weiss bf66e8f1b4 more forgotten tests added 2017-09-25 13:00:35 +01:00
Johannes Weiß 8e06697362 fix EventLoop shutdown by introducing shutdownGracefully 2017-09-20 17:15:06 +01:00
Johannes Weiß eff809b88d add forgotten Linux tests 2017-09-20 17:43:16 +01:00
Cory Benfield 007feec636 Add Unix domain socket support part 2: Electric Boogaloo
* support UNIX Domain Sockets

* Add test for connect: with UDS path

* Add UDS-special connect method
2017-09-21 15:26:37 +01:00
Johannes Weiss 6721d46b9d make scheduling tasks on the EventLoop compatible with the tail call syntax 2017-09-18 16:24:08 +01:00
Johannes Weiss da905d17f8 channelInactive should fire before channelUnregistered 2017-09-18 14:42:35 +01:00
Johannes Weiß 3ea35268d4 fully close Channel before firing channelInactive/Unregistered 2017-09-15 18:29:20 +01:00
Cory Benfield 4c37eee3f8 Pipelines that write before they read must remain readable.
* Test that we can write and then read

* Correctly unregister writability
2017-09-15 16:41:52 +01:00
Cory Benfield 537a555877 Test that connect fires channelActive 2017-09-15 10:00:31 +01:00
Cory Benfield bcdbe4bc46 ChannelHandlerContext.connect shouldn't bind 2017-09-15 09:29:59 +01:00
Cory Benfield 0c3d04580b Correctly try to unwrap InboundIn 2017-09-13 08:26:07 +01:00
Cory Benfield 6ddd130890 Add channel handler tests 2017-09-11 14:31:47 +01:00
Norman Maurer ca7aac3253 Allow to cancel scheduled tasks 2017-08-18 14:07:17 +02:00
Norman Maurer b2405eac44 Add support to schedule tasks on the EventLoop 2017-08-17 13:50:32 +02:00
Norman Maurer 1619c3d7c8 Add support for sendFile by allow to write a FileRegion. 2017-08-11 20:32:04 +02:00
Norman Maurer 67e2359a8f Use a random port for testing to ensure we not run into any conflicts 2017-08-12 10:05:43 +02:00
Johannes Weiß f42420f0d2 circular buffer for pending writes 2017-08-11 17:05:58 +01:00
Norman Maurer 24ce812c31 Ensure swift-nio compiles on latest swift 4.0 snapshot 2017-08-08 13:25:57 +02:00
Norman Maurer a708c33008 Fix Channel.connect(...) and add unit test that shows using swift-nio to build clients / servers work 2017-08-08 13:52:40 +02:00
Johannes Weiß 0684750261 minor fixes 2017-08-08 15:48:56 +01:00
Kevin Clark 78ba7a819e Make HTTPHeaders iterate with originalcase'd names
* Make HTTPHeaders iterate with originalcase'd names

Interface change as a consequence of this: now iterating headers
produces (name, value) tuples rather than (name, [values]).

* Add linux test wrapper

* Add case insensitive lookup test

* Update generate test headers

* Make HTTPHeadersIterator private
2017-07-24 12:55:12 -07:00
Johannes Weiß 0213e53f49 description for SocketAddress 2017-07-21 17:18:09 +01:00
Kevin Clark ed98bffe28 Renames and cleanup
* Massage HTTPHeaders

Simple had it's own version that was the same aside from a couple of
minor tweaks.

* Default initializer for HTTPHeaders

* Rename HTTPRequest -> HTTPRequestPart

* HTTPResponse -> HTTPResponsePart

* Add HTTPVersion(major:,minor:)

* Allow access to HTTPVersion.major/minor

* Comments on HTTP response codes

* Fix tests (needed rename applied)
2017-07-18 10:38:23 -07:00
Norman Maurer 3c604f90dd Move ByteBuffer.string(...) to ByteBuffer-aux 2017-07-10 15:50:24 +02:00
Kevin Clark 145e8328c4 Futures init'd with errors/results are already fulfilled
* Futures init'd with errors/results are fulfilled

They automatically succeed/fail when new callbacks are added, so
semantically they're already fulfilled, no?

Without this, EventLoop.newSucceedFuture 'leaks' and explodes in the
provided tests.

* Regenerate linux tests

* Add missing generated extension for linux CI
2017-07-07 00:04:45 -07:00
Norman Maurer 9d535bad22 Let writeInbound and writeOutbound signal if something was put in the buffer to consume and update the tests 2017-07-06 14:33:57 +02:00
Norman Maurer 2d235020d0 Add EmbeddedChannel.writeInbound|Outbound methods which make it easier to use EmbbeddedChannel for testing etc 2017-07-06 11:08:48 +02:00
Norman Maurer c12620e813 Directly use malloc/free when allocate ByteBuffer and also use realloc when change the size of the _Storage 2017-07-05 18:13:55 +02:00
Johannes Weiß c09178ceb2 baby steps towards a type-safe Channel pipeline 2017-06-30 13:04:19 +01:00
Johannes Weiss 15677b9fc2 fix tests 2017-07-04 15:29:41 +01:00
Norman Maurer 614f689e05 Improve the EmbeddedChannel to be able to easily capture inbound and outbound messages 2017-07-04 12:16:00 +02:00
Norman Maurer 4127580f8b Port MessageToByteEncoder from netty 2017-07-04 08:45:40 +02:00