-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
caddyhttp: Make use of http.ResponseController
#5654
Conversation
Linter doesn't like this new pattern. Opened an issue: timakin/bodyclose#52 Also the Go stdlib code we ported ignores the |
2058dec
to
11be9d1
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.
Thanks, this definitely looks more elegant than what we were doing before.
I imagine there aren't external repos using our HTTPInterfaces type?
11be9d1
to
8bde678
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 now. Thank you for contributing this!
I'd just like @WeidiDeng to give his 👍 on this as well in case I missed something. |
There is something about |
Hmm. I'm not sure what we would type assert at all. We already know it's a ResponseWriter. Do we even need wrapping now that response controller lets us call those optional interfaces in a unified way? Does our wrapper add any value, or is it necessary for it to work properly? If you have a suggestion, feel free to commit it 🤔 I'm not sure I follow. |
I mean like this:
|
Aaah I see, so don't re-wrap if it's already wrapped. Makes sense. |
Also syncs the reverseproxy implementation with stdlib's which now uses ResponseController as well golang/go@2449bbb
8bde678
to
fb8c245
Compare
Thanks, pushed that fix. Do you notice anything else? |
I'll probably merge this in a few minutes to a few hours (before I have to take off for some family stuff today) so I can tag 2.7. Thank you for working on this! |
And @WeidiDeng thank you for your invaluable review and contributions 🙏 |
One part of #5288, should fix #5431 (if built with Go 1.21+).
Adds a new
enable_full_duplex
server global option to opt-in (only effectual for Go 1.21+, with ago:build
constraint). I think it needs to be opt-in because it could cause deadlocks if the client doesn't know how to handle a connection in that mode, but it seems necessary to turn on for certain kinds of apps. Maybe this should be an HTTP handler (maybe as a new option for https://caddyserver.com/docs/caddyfile/directives/request_body) which would allow using matchers to conditionally enable it instead of enabling it for all connections to the server 🤔 But I marked this as experimental so we can adjust later if needed.The other main aspect of this is dropping
caddyhttp.HTTPInterfaces
because it's now made redundant byhttp.ResponseController
which gives a way to use these optional interfaces without type assertions. Simplifies code in most cases.Also syncs the reverseproxy implementation with stdlib's which now uses ResponseController as well; see golang/go@2449bbb for the original diff that I ported over.
And finally, minor improvement,
io.Copy()
already triesio.ReaderFrom
so we don't need to do that ourselves inresponsewriter.go
.