mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-30 05:28:45 +00:00
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:
1 parent
392b2e3228
commit
346af5be0e
7 files changed
+109
-8
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user