-
Notifications
You must be signed in to change notification settings - Fork 124
Prepare async/await API for public release #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
private let stream: IteratorStream | ||
|
||
fileprivate init(stream: IteratorStream) { | ||
self.stream = stream | ||
} | ||
|
||
func next() async throws -> ByteBuffer? { | ||
public func next() async throws -> ByteBuffer? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question rather than suggestion: should this be mutating
to indicate that next()
consumes from the stream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. @fabianfett any objections?
@@ -12,9 +12,16 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
enum RequestBodyLength: Hashable { | |||
public struct RequestBodyLength { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not add this type without prefix to the top namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I have reverted the change and added a new public type HTTPClientRequest.Body.Length
which is baked by RequestBodyLength
and used as the public type instead.
509784b
to
2702cb0
Compare
extension HTTPClientRequest.Body { | ||
public struct Length { | ||
/// size of the request body is not known before starting the request | ||
public static let dynamic: Self = .init(storage: .dynamic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is dynamic the right name here? What about unknown
?
I like the storage workaround btw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw. fixed is also weird. I guess known
would be more appropriate. Also I think this type should be ExpressibleByIntegerLiteral
.
@swift-server-bot test this please |
and add nescary @inlinable/@usableFromInlinable for generic `HTTPClientReuqest.Body` builder metods.
f8bab65
to
10b8bd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
HTTPClientReuqest.Body
builder metods.HTTPClientReuqest.Body.byteBuffer(_:)
toHTTPClientReuqest.Body.bytes(_:)
to be more in line with the other overloadsHTTPClientReuqest.Body.Length
instead ofInt?
to specify the length of a body if we can't infer the lengthlength
parameter to the end