Skip to content

Commit 5e9a9cc

Browse files
Improved documentation for HTTP Parts to clarify how often each part is received (#2775)
1 parent 2798a6e commit 5e9a9cc

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Sources/NIOHTTP1/HTTPTypes.swift

+21-6
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,30 @@ public struct HTTPRequestHead: Equatable {
125125

126126
extension HTTPRequestHead: @unchecked Sendable {}
127127

128-
/// The parts of a complete HTTP message, either request or response.
129-
///
130-
/// A HTTP message is made up of a request or status line with several headers,
131-
/// encoded by `.head`, zero or more body parts, and optionally some trailers. To
132-
/// indicate that a complete HTTP message has been sent or received, we use `.end`,
133-
/// which may also contain any trailers that make up the message.
128+
/// The parts of a complete HTTP message, representing either a request or a response.
129+
///
130+
/// An HTTP message is made up of:
131+
/// - a request or status line with several headers, encoded by a single ``HTTPPart/head(_:)`` part,
132+
/// - zero or more ``HTTPPart/body(_:)`` parts,
133+
/// - and some optional trailers (represented as headers) in a single ``HTTPPart/end(_:)`` part.
134+
///
135+
/// To indicate that a complete HTTP message has been sent or received,
136+
/// an ``HTTPPart/end(_:)`` part must be used, even when no trailers are included.
134137
public enum HTTPPart<HeadT: Equatable, BodyT: Equatable> {
138+
/// The headers of an HTTP request or response.
139+
///
140+
/// A single part is always used to encode all headers.
135141
case head(HeadT)
142+
143+
/// A part of an HTTP request or response's body.
144+
///
145+
/// Zero or more body parts can be sent or received. The stream is finished when
146+
/// an ``HTTPPart/end(_:)`` part is received.
136147
case body(BodyT)
148+
149+
/// The end of an HTTP request or response, optionally containing trailers.
150+
///
151+
/// A single part is always used to encode all trailers.
137152
case end(HTTPHeaders?)
138153
}
139154

0 commit comments

Comments
 (0)