Commit Graph
57 Commits
Author SHA1 Message Date
David NadobaandGitHub 4fd1150184 Fix bodyLengthMissmatch error handling (#490) 2021-11-24 15:46:51 +01:00
David NadobaandGitHub 0ed00b8b36 Always overwrite Transport-Encoding and Content-Length headers (#479) 2021-11-23 10:22:57 +01:00
David NadobaandGitHub b479afe4c8 Fix bug in migration from HTTP1 to HTTP2 and back to HTTP1 (#486) 2021-11-22 12:33:57 +01:00
Fabian FettandGitHub 2fe3f42fee Crash fix: HTTP2Connections emit events after the pool has closed them. (#481) 2021-11-19 12:33:08 +01:00
David NadobaandGitHub 1f3f141038 Remove redundant RequestFramingMetadata.Body.none case (#480) 2021-11-18 17:13:38 +01:00
7617c35db3 Handle NIOSSLError.uncleanShutdown correctly (#472)
### Motivation

Fixes #238 and #231.

### Changes

- Extracted the unclean shutdown test from `HTTPClientTests` into their own file `HTTPClientUncleanSSLConnectionShutdownTests`
- Copy and pasted @weissi great explanation from #238 into the test file
- Removed property `ignoreUncleanSSLShutdown` everywhere

### Result

`ignoreUncleanSSLShutdown` on `HTTPClient.Configuration` is deprecated and ignored.

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2021-11-11 11:02:54 +01:00
Fabian FettandGitHub 170fd536f9 Support informational response heads (#469) 2021-11-10 13:33:38 +01:00
David NadobaandGitHub 7d1ed4cca5 [HTTP2] Forward HTTP2 events to StateMachine (#466) 2021-11-04 10:48:12 +00:00
David NadobaandGitHub 18a58bb874 [HTTP2] Improve performance of backoff timer done event (#464) 2021-11-03 14:29:24 +00:00
David NadobaandGitHub 60fef53db7 [HTTP2] Internal HTTPVersion configuration (#463) 2021-11-02 18:46:29 +00:00
David NadobaandGitHub 149b8d2656 [HTTP2] Integrate HTTP2StateMachine into HTTPConnectionPool.StateMachine (#462) 2021-11-02 11:51:18 +00:00
David NadobaandGitHub 4147fd647d [HTTP2] Create new connections during migration if needed (#459) 2021-10-27 18:28:51 +02:00
David NadobaandGitHub c1a60d8aa4 [HTTP2] Prepare migration actions (#456) 2021-10-13 17:11:04 +02:00
Cory BenfieldandGitHub 1081b0b054 Don't crash when hitting long backoffs. (#458)
Motivation:

If we backoff sufficiently far we can overflow Int64, which will cause
us to crash.

Modifications:

Clamp the backoff value before we convert to Int64.

Results:

No crashes!
2021-10-13 13:09:54 +01:00
David NadobaandGitHub d5bd8d6526 Always clear read idle timeout at the end of a request (#455) 2021-10-08 16:29:28 +02:00
David NadobaandGitHub a0b09857d8 [HTTP2StateMachine] test and fix HTTP2 go away (#452) 2021-10-05 13:59:09 +02:00
David NadobaandGitHub a57c4b309c [HTTP2ConnectionPool] added HTTP2StateMachine (#447) 2021-10-05 11:19:41 +02:00
David NadobaandGitHub 96963810cb [HTTP2Connections] Return if connection was idle before lease (#451) 2021-10-02 14:06:13 +02:00
Fabian FettandGitHub d928cc81b3 [HTTPRequestStateMachine] Allow channelReadComplete at any time (#450) 2021-10-01 13:59:51 +02:00
Fabian FettandGitHub a6ca288e18 [HTTPConnectionPool] StateMachine has explicit function for HTTP1 connection close (#448) 2021-10-01 12:50:13 +02:00
David NadobaandGitHub e4e233a2b1 remove umbrella NIO imports and add soundness check (#446) 2021-09-29 17:42:42 +02:00
David NadobaandGitHub 628b942522 prepare calculateBackoff(failedAttempt:) to be used in HTTP2StateMachine (#445) 2021-09-29 16:43:10 +02:00
David NadobaandGitHub 88d47f12ca [HTTP2ConnectionPool] added HTTP2Connections struct (#440)
One step closer to support HTTP/2 in the new connection pool. 
`HTTP2Connections` will be used in a new `HTTP2StateMaschine` in a follow up PR.
2021-09-28 12:06:54 +02:00
Fabian FettandGitHub 16ad7588b1 [HTTP1Connection] Handle 101 Switching Protocols (#442) 2021-09-28 09:52:26 +02:00
Fabian FettandGitHub 2a47a1da75 [HTTPClient.Configuration] Make connection pool size configurable (#437) 2021-09-27 09:35:40 +02:00
Fabian FettandGitHub dca46a92f0 [HTTPConnectionPool] Fix request timer scheduling (#438) 2021-09-24 15:38:19 +02:00
Fabian FettandGitHub 2565dfe0dc [HTTPConnectionPool] Implementation switch (#427) 2021-09-24 09:28:09 +02:00
Fabian FettandGitHub 0bce647a2f [HTTPConnectionPool] Fix timer action races (#434)
- `_idleTimer` and `_backoffTimer` are protected by `stateLock`
- Added a new `struct Actions` that splits up actions from the state machine into actions that need to be executed inside the `stateLock` and outside in `stateLock`
- Add HTTP/1.1 connection pool stress test
2021-09-22 16:47:26 +02:00
Fabian FettandGitHub d45fa9a0bd [HTTPConnectionPool] Move Connections down in the file (#433) 2021-09-22 15:35:41 +01:00
Fabian FettandGitHub 64fbfdaeda [HTTP1Connection] Option to ignore unclean ssl shutdown errors (#432)
- a new `RequestOptions` struct was created, that can be used to set request specific options. It is required by the `HTTPExecutableRequest`
- Added support for `ignoreUncleanSSLShutdown` in the `HTTPRequestStateMachine` and the `HTTP1ConnectionStateMachine`. In http/2 `ignoreUncleanSSLShutdown` is always off.
2021-09-21 10:04:17 +02:00
Fabian FettandGitHub b25943adad Fix HTTP/1.0 support (#431)
Use `HTTPResponseHead.isKeepAlive` instead of relying on our own keep-alive test.
2021-09-20 18:16:13 +02:00
Fabian FettandGitHub bef8878ede ChannelRead because of closing connection: Remove preconditions (#430)
### Motivation

NIO may send `channelRead` events without a handlers requesting more data with a `context.read()` invocation. This happens if the remote has closed the connection and NIO wants to inform the handlers as soon as possible.

### Changes

- Don't `precondition` on `channelRead` events anymore.
- Close channel if we received an http end without a `context.read()` invocation
2021-09-20 18:11:04 +02:00
Fabian FettandGitHub 7c9662d31c Add logging to the new ConnectionPool (#428) 2021-09-20 16:23:09 +02:00
Fabian FettandGitHub 324adb73ae HTTP1Connection: Close on error while in request (#425)
### Motivation

In the `HTTP1ConnectionStateMachine` we set the connection state to `.closed` after having forwarded an error to the inner RequestStateMachine. Since we set the state to close, the `state.modify` function did not create an action that would close the connection.

### Changes

- Modify the ConnectionState based on the RequestStateMachine's action only in the `state.modify` function.
- Add a test to verify the fixed behavior.
- Use ExpressibleByDictionaryLiteral syntax for some HTTPHeaders to increase readability.

### Result

Connections are closed, if an error happens, while we are in a request.
2021-09-14 10:27:32 +02:00
Fabian FettandGitHub 0c36de21d6 HTTPConnectionPool timeout requests: preserve connection errors
If a request times out because no connection could be attained, we should fail the request with the last connection creation error. If no connection creation error is present and there is no active connection, we fail the request with a connectTimeout error.
2021-09-13 18:22:29 +02:00
Fabian FettandGitHub 5d2bf9250d Ensure HTTPConnectionPool calls shutdown on active connections. (#422)
Trigger the correct method on HTTPConnectionPool.Connection to cancel the request and close the connection.
2021-09-13 14:57:18 +02:00
fb49c1be5f Add new HTTPConnectionPool Manager (#420)
Co-authored-by: George Barnett <gbarnett@apple.com>
2021-09-10 17:25:41 +02:00
Fabian FettandGitHub 7bb58e536c Fix a race between shutdown and backoff timer (#419) 2021-09-09 17:01:07 +02:00
Fabian FettandGitHub 4d726bad8d Add ConnectionPool HTTP1StateMachine (#416) 2021-09-09 15:34:03 +02:00
05e570dd87 Add MockTools for testing HTTP1ConnectionPool.StateMachine (#417)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-09-08 17:45:09 +02:00
Fabian FettandGitHub 4068ee50d0 EventLoop preferences (#415) 2021-09-07 10:47:09 +01:00
7d3c578472 HTTP1Connections state machine for ConnectionPool (#413)
Co-authored-by: George Barnett <gbarnett@apple.com>
2021-09-06 12:56:20 +02:00
Fabian FettandGitHub 1f5b633457 Add a RequestQueue for the ConnectionPool (#412) 2021-09-01 13:55:06 +02:00
Fabian FettandGitHub eab2a84b1c Use explicit NIO imports (#407)
* Use explicit NIO imports for `NIOCore`, `NIOPosix` and `NIOEmbedded`
* Updated dependencies
2021-08-19 21:11:49 +02:00
Fabian FettandGitHub 44efb9481b Cleanup: Connection cancel -> shutdown (#404)
* Cleanup

* Code review
2021-07-23 11:52:46 +01:00
388b8dc14a Add HTTP2Connection (#401)
Co-authored-by: George Barnett <gbarnett@apple.com>
2021-07-22 18:30:37 +02:00
Fabian FettandGitHub e967f9a099 Add HTTP1Connection (#400) 2021-07-13 13:32:18 +02:00
Fabian FettandGitHub 79db46a757 HTTPSchedulableRequest extends HTTPExecutableRequest (#402) 2021-07-09 11:12:14 +01:00
Fabian FettandGitHub 152c21e45a Add HTTPConnectionPool Connection as a box type (#398)
Add a `HTTPConnectionPool.Connection` type that is a box around an actual connection. The purpose of the box is to ensure no actions are invoked on the connection within the state machine. Further the box can be used for testing the state machine without creating actual connections.
2021-07-09 10:13:35 +02:00
Fabian FettandGitHub 7311c0ecfe Add a request waiter box for the connection pool (#397) 2021-07-08 18:57:00 +02:00