mirror of
https://github.com/apple/swift-nio-extras
synced 2026-11-28 05:14:24 +00:00
Migrate CI to use GitHub Actions. (#234)
### Motivation: To migrate to GitHub actions and centralised infrastructure. ### Modifications: Changes of note: * Adopt swift-format using rules from SwiftNIO * Remove scripts and docker files which are no longer needed ### Result: Feature parity with old CI.
This commit is contained in:
1 parent
11b7d82b51
commit
3f776e9aaf
125 files changed
+4697
-3338
No files matched your search
@@ -91,23 +91,23 @@ struct HTTP2HeadersStateMachine {
|
||||
// The first header block received on a server mode stream must be a request block.
|
||||
newType = .requestHead
|
||||
case (.client, .none),
|
||||
(.client, .some(.informationalResponseHead)):
|
||||
(.client, .some(.informationalResponseHead)):
|
||||
// The first header block received on a client mode stream may be either informational or final,
|
||||
// depending on the value of the :status pseudo-header. Alternatively, if the previous
|
||||
// header block was informational, the same possibilities apply.
|
||||
newType = try block.isInformationalResponse() ? .informationalResponseHead : .finalResponseHead
|
||||
case (.server, .some(.requestHead)),
|
||||
(.client, .some(.finalResponseHead)):
|
||||
(.client, .some(.finalResponseHead)):
|
||||
// If the server has already received a request head, or the client has already received a final response,
|
||||
// this is a trailer block.
|
||||
newType = .trailer
|
||||
case (.server, .some(.informationalResponseHead)),
|
||||
(.server, .some(.finalResponseHead)),
|
||||
(.client, .some(.requestHead)):
|
||||
(.server, .some(.finalResponseHead)),
|
||||
(.client, .some(.requestHead)):
|
||||
// These states should not be reachable!
|
||||
preconditionFailure("Invalid internal state!")
|
||||
case (.server, .some(.trailer)),
|
||||
(.client, .some(.trailer)):
|
||||
(.client, .some(.trailer)):
|
||||
// TODO(cory): This should probably throw, as this can happen in malformed programs without the world ending.
|
||||
preconditionFailure("Sending too many header blocks.")
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ private struct BaseClientCodec {
|
||||
|
||||
private var outgoingHTTP1RequestHead: HTTPRequest?
|
||||
|
||||
mutating func processInboundData(_ data: HTTP2Frame.FramePayload) throws -> (first: HTTPResponsePart?, second: HTTPResponsePart?) {
|
||||
mutating func processInboundData(
|
||||
_ data: HTTP2Frame.FramePayload
|
||||
) throws -> (first: HTTPResponsePart?, second: HTTPResponsePart?) {
|
||||
switch data {
|
||||
case .headers(let headerContent):
|
||||
switch try self.headerStateMachine.newHeaders(block: headerContent.headers) {
|
||||
@@ -68,13 +70,17 @@ private struct BaseClientCodec {
|
||||
}
|
||||
}
|
||||
return (first: first, second: second)
|
||||
case .alternativeService, .rstStream, .priority, .windowUpdate, .settings, .pushPromise, .ping, .goAway, .origin:
|
||||
case .alternativeService, .rstStream, .priority, .windowUpdate, .settings, .pushPromise, .ping, .goAway,
|
||||
.origin:
|
||||
// These are not meaningful in HTTP messaging, so drop them.
|
||||
return (first: nil, second: nil)
|
||||
}
|
||||
}
|
||||
|
||||
mutating func processOutboundData(_ data: HTTPRequestPart, allocator: ByteBufferAllocator) throws -> HTTP2Frame.FramePayload {
|
||||
mutating func processOutboundData(
|
||||
_ data: HTTPRequestPart,
|
||||
allocator: ByteBufferAllocator
|
||||
) throws -> HTTP2Frame.FramePayload {
|
||||
switch data {
|
||||
case .head(let head):
|
||||
precondition(self.outgoingHTTP1RequestHead == nil, "Only a single HTTP request allowed per HTTP2 stream")
|
||||
@@ -85,10 +91,12 @@ private struct BaseClientCodec {
|
||||
return .data(HTTP2Frame.FramePayload.Data(data: .byteBuffer(body)))
|
||||
case .end(let trailers):
|
||||
if let trailers {
|
||||
return .headers(.init(
|
||||
headers: HPACKHeaders(trailers),
|
||||
endStream: true
|
||||
))
|
||||
return .headers(
|
||||
.init(
|
||||
headers: HPACKHeaders(trailers),
|
||||
endStream: true
|
||||
)
|
||||
)
|
||||
} else {
|
||||
return .data(.init(data: .byteBuffer(allocator.buffer(capacity: 0)), endStream: true))
|
||||
}
|
||||
@@ -134,7 +142,10 @@ public final class HTTP2FramePayloadToHTTPClientCodec: ChannelDuplexHandler, Rem
|
||||
let requestPart = self.unwrapOutboundIn(data)
|
||||
|
||||
do {
|
||||
let transformedPayload = try self.baseCodec.processOutboundData(requestPart, allocator: context.channel.allocator)
|
||||
let transformedPayload = try self.baseCodec.processOutboundData(
|
||||
requestPart,
|
||||
allocator: context.channel.allocator
|
||||
)
|
||||
context.write(self.wrapOutboundOut(transformedPayload), promise: promise)
|
||||
} catch {
|
||||
promise?.fail(error)
|
||||
@@ -148,7 +159,9 @@ public final class HTTP2FramePayloadToHTTPClientCodec: ChannelDuplexHandler, Rem
|
||||
private struct BaseServerCodec {
|
||||
private var headerStateMachine: HTTP2HeadersStateMachine = .init(mode: .server)
|
||||
|
||||
mutating func processInboundData(_ data: HTTP2Frame.FramePayload) throws -> (first: HTTPRequestPart?, second: HTTPRequestPart?) {
|
||||
mutating func processInboundData(
|
||||
_ data: HTTP2Frame.FramePayload
|
||||
) throws -> (first: HTTPRequestPart?, second: HTTPRequestPart?) {
|
||||
switch data {
|
||||
case .headers(let headerContent):
|
||||
if case .trailer = try self.headerStateMachine.newHeaders(block: headerContent.headers) {
|
||||
@@ -183,7 +196,10 @@ private struct BaseServerCodec {
|
||||
}
|
||||
}
|
||||
|
||||
mutating func processOutboundData(_ data: HTTPResponsePart, allocator: ByteBufferAllocator) -> HTTP2Frame.FramePayload {
|
||||
mutating func processOutboundData(
|
||||
_ data: HTTPResponsePart,
|
||||
allocator: ByteBufferAllocator
|
||||
) -> HTTP2Frame.FramePayload {
|
||||
switch data {
|
||||
case .head(let head):
|
||||
let payload = HTTP2Frame.FramePayload.Headers(headers: HPACKHeaders(head))
|
||||
@@ -193,10 +209,12 @@ private struct BaseServerCodec {
|
||||
return .data(payload)
|
||||
case .end(let trailers):
|
||||
if let trailers {
|
||||
return .headers(.init(
|
||||
headers: HPACKHeaders(trailers),
|
||||
endStream: true
|
||||
))
|
||||
return .headers(
|
||||
.init(
|
||||
headers: HPACKHeaders(trailers),
|
||||
endStream: true
|
||||
)
|
||||
)
|
||||
} else {
|
||||
return .data(.init(data: .byteBuffer(allocator.buffer(capacity: 0)), endStream: true))
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ private enum HTTP2TypeConversionError: Error {
|
||||
case pseudoFieldInTrailers
|
||||
}
|
||||
|
||||
private extension HPACKIndexing {
|
||||
init(_ newIndexingStrategy: HTTPField.DynamicTableIndexingStrategy) {
|
||||
extension HPACKIndexing {
|
||||
fileprivate init(_ newIndexingStrategy: HTTPField.DynamicTableIndexingStrategy) {
|
||||
switch newIndexingStrategy {
|
||||
case .avoid: self = .nonIndexable
|
||||
case .disallow: self = .neverIndexed
|
||||
@@ -42,8 +42,8 @@ private extension HPACKIndexing {
|
||||
}
|
||||
}
|
||||
|
||||
private extension HTTPField.DynamicTableIndexingStrategy {
|
||||
init(_ oldIndexing: HPACKIndexing) {
|
||||
extension HTTPField.DynamicTableIndexingStrategy {
|
||||
fileprivate init(_ oldIndexing: HPACKIndexing) {
|
||||
switch oldIndexing {
|
||||
case .indexable: self = .automatic
|
||||
case .nonIndexable: self = .avoid
|
||||
@@ -221,7 +221,8 @@ extension HTTPResponse {
|
||||
throw HTTP2TypeConversionError.missingStatus
|
||||
}
|
||||
guard let status = Int(statusString),
|
||||
(0 ... 999).contains(status) else {
|
||||
(0...999).contains(status)
|
||||
else {
|
||||
throw HTTP2TypeConversionError.invalidStatus
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user