We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
io.Copy无法保证实时转发streaming流,需要改进
`buf := make([]byte, 1024*1024) // 1MB buffer for {
n, err := resp.Body.Read(buf) if err != nil && err != io.EOF { http.Error(w, err.Error(), http.StatusInternalServerError) return } if n == 0 { break } if _, err := w.Write(buf[:n]); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } w.(http.Flusher).Flush()
}`
The text was updated successfully, but these errors were encountered:
请教 io.Copy 不能实时转发的原因可能是什么? 我注意到这里代码有一条 w.(http.Flusher).Flush() ,这是修复实时性的关键吗?
w.(http.Flusher).Flush()
Sorry, something went wrong.
io.Copy 有内存缓冲区的 缓冲区满了才会返回
No branches or pull requests
io.Copy无法保证实时转发streaming流,需要改进
`buf := make([]byte, 1024*1024) // 1MB buffer
for {
}`
The text was updated successfully, but these errors were encountered: