don't crash when client sends bad magic (#12)

Motivation:

We shouldn't just crash if the client sends bad magic.

Changes:

Send an error through the pipeline instead of crashing on bad client
magic.

Result:

fewer crashes
This commit is contained in:
Johannes Weiss authored and Cory Benfield committed 2018-08-16 15:29:14 +01:00
1 parent 392b2e3228
commit 346af5be0e
7 files changed
+109 -8

No files matched your search

+14
View File
@@ -12,6 +12,8 @@
//
//===----------------------------------------------------------------------===//
import CNIONghttp2
public protocol NIOHTTP2Error: Equatable, Error { }
/// Errors that NIO raises when handling HTTP/2 connections.
@@ -45,6 +47,18 @@ public enum NIOHTTP2Errors {
self.errorCode = errorCode
}
}
public struct BadClientMagic: NIOHTTP2Error {
public init() {}
}
public struct InternalError: NIOHTTP2Error {
internal var nghttp2ErrorCode: nghttp2_error
internal init(nghttp2ErrorCode: nghttp2_error) {
self.nghttp2ErrorCode = nghttp2ErrorCode
}
}
}