-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
2.x.x - Trailer headers #330
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x.x #330 +/- ##
==========================================
+ Coverage 83.08% 83.12% +0.03%
==========================================
Files 92 92
Lines 5037 5048 +11
==========================================
+ Hits 4185 4196 +11
Misses 852 852 ☔ View full report in Codecov by Sentry. |
Pull request benchmark comparison [ubuntu-latest] with '2.x.x' run at 2024-01-05T10:43:29+00:00 |
Many users won't use the trailing headers, does it make sense to support an additional closure that's (still) defines as |
I tried having two different |
/// written | ||
public static func withTrailingHeaders( | ||
contentLength: Int? = nil, | ||
_ write: @Sendable @escaping (any HBResponseBodyWriter) async throws -> HTTPFields? |
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.
I like this a lot better, now one more idea to play with: Can we make the any HBResponseBodyWriter
an inout
? This would make it harder to incorrectly wield this API.
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.
I'm not sure what you are getting at there. What do we gain from making any HBResponseBodyWriter
inout
. That closure is called by HTTPChannelHandler
and any Middleware that want to process response bodies. ie very few people will be calling it.
Are you seeing a situation where you would want to the write function to mutate the HBResponseBodyWriter
?
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.
No, I don't see a situation where we'd want to mutate. I see a risk in people trying to escape that HBResponseBodyWriter out of this closure
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.
I don't want to hold up this PR for this topic though, since it's not caused by this PR
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.
ok I see, by making it inout you make it harder but it could still be done. I could make ~Copyable
I don't know if that'd help
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.
Forgot that HBResponseBodyWriter is a protocol not a struct
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.
Adding an issue to chase this up #342
cf5e76a
to
39d0843
Compare
Trailer headers are output as the return value from the response body writer