Docnioextras (#169)

* Improve documentation for NIOExtras

Motivation:

Docs will help users do things correctly.

Modifications:

Add missing comments, improve links.

Result:

Better docc documentation

* Docc in NIOHTTPCompression

* NIOSOCKS docc

* Correct bad symbol

* Minor typo

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
Peter AdamsandCory Benfield authored and GitHub committed 2022-08-03 01:34:45 -07:00
1 parent ca22c12528
commit da7c04777b
27 files changed
+393 -116

No files matched your search

@@ -16,7 +16,7 @@ import CNIOExtrasZlib
import NIOCore
import NIOHTTP1
/// NIOHTTPResponseCompressor is an outbound channel handler that handles automatic streaming compression of
/// ``NIOHTTPRequestCompressor`` is an outbound channel handler that handles automatic streaming compression of
/// HTTP requests.
///
/// This compressor supports gzip and deflate. It works best if many writes are made between flushes.
@@ -27,7 +27,9 @@ import NIOHTTP1
/// benefit. This channel handler should be present in the pipeline only for dynamically-generated and
/// highly-compressible content, which will see the biggest benefits from streaming compression.
public final class NIOHTTPRequestCompressor: ChannelOutboundHandler, RemovableChannelHandler {
/// Class takes `HTTPClientRequestPart` as the type to send.
public typealias OutboundIn = HTTPClientRequestPart
/// Passes `HTTPClientRequestPart` to the next stage in the pipeline when sending.
public typealias OutboundOut = HTTPClientRequestPart
/// Handler state
@@ -53,18 +55,22 @@ public final class NIOHTTPRequestCompressor: ChannelOutboundHandler, RemovableCh
/// pending write promise
var pendingWritePromise: EventLoopPromise<Void>!
/// Initialize a NIOHTTPRequestCompressor
/// Initialize a ``NIOHTTPRequestCompressor``
/// - Parameter encoding: Compression algorithm to use
public init(encoding: NIOCompression.Algorithm) {
self.encoding = encoding
self.state = .idle
self.compressor = NIOCompression.Compressor()
}
/// Add handler to the pipeline.
/// - Parameter context: Calling context.
public func handlerAdded(context: ChannelHandlerContext) {
pendingWritePromise = context.eventLoop.makePromise()
}
/// Remove handler from pipeline.
/// - Parameter context: Calling context.
public func handlerRemoved(context: ChannelHandlerContext) {
pendingWritePromise.fail(NIOCompression.Error.uncompressedWritesPending)
compressor.shutdownIfActive()