You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of the standard lib implementation uses a wrapper of the response writer to capture status and other information. While it does conform to the interfaces required function it does not implement optional interfaces which are useful. As the this is run as a middleware before any handlers it means that all handlers will receive the wrapped response writer which as well.
This has the most noticeable impact when using io copy to write from a reader, as a zero copy system call will not be used. Instead Go will fallback to using an in memory buffer instead.
It is not the most logical side effect, and it is pretty easy to miss as the response writer is hidden and itself does not do a good job documenting the additional optional interfaces.
My suggestion is that we implement the ReadFrom function on the response writer so that io copy will work more efficiently for all users who may not be aware of the issue.
The text was updated successfully, but these errors were encountered:
The current implementation of the standard lib implementation uses a wrapper of the response writer to capture status and other information. While it does conform to the interfaces required function it does not implement optional interfaces which are useful. As the this is run as a middleware before any handlers it means that all handlers will receive the wrapped response writer which as well.
This has the most noticeable impact when using io copy to write from a reader, as a zero copy system call will not be used. Instead Go will fallback to using an in memory buffer instead.
It is not the most logical side effect, and it is pretty easy to miss as the response writer is hidden and itself does not do a good job documenting the additional optional interfaces.
Here is a good blog post that explains the issue well.
https://avtok.com/2014/11/05/interface-upgrades.html
My suggestion is that we implement the ReadFrom function on the response writer so that io copy will work more efficiently for all users who may not be aware of the issue.
The text was updated successfully, but these errors were encountered: