-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
net/ghttp: stream content might be splitted #3584
Comments
|
下面是gin的例子 同样输出的内容 gin不会断开
|
试试用Writefln,在使用中还没有出现过截断 |
|
试过了 不行 截断的情况只有在移动端才能复现 |
I tried it, but it didn’t work. The truncation situation can only be reproduced on the mobile terminal. |
@lcm1475 请尝试使用文档的 package main
import (
"fmt"
"net/http"
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
func main() {
s := g.Server()
s.BindHandler("/", func(r *ghttp.Request) {
rw := r.Response.RawWriter()
flusher, ok := rw.(http.Flusher)
if !ok {
http.Error(rw, "Streaming unsupported!", http.StatusInternalServerError)
return
}
r.Response.Header().Set("Content-Type", "text/event-stream")
r.Response.Header().Set("Cache-Control", "no-cache")
r.Response.Header().Set("Connection", "keep-alive")
for i := 0; i < 100; i++ {
_, err := fmt.Fprintf(rw, "data: %d\n", i)
if err != nil {
panic(err)
}
flusher.Flush()
time.Sleep(time.Millisecond * 200)
}
})
s.SetPort(8999)
s.Run()
} |
Go version
go version go1.21.5 darwin/arm64
GoFrame version
v2.6.1
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
gf的流式输出在移动端会断开把一次的数据截断成2次发送,同样的代码放到gin就没问题
而且这个情况web看不出来,打印输出到web页面上是没问题的,移动端才能复现这个问题,Android,ios,Flutter,这些移动端必现,但是Android,ios,Flutter这些接入官方的openai,bing,文心,或者gin都是正常的,只有gf会断开,
把数据缩短好像断开的情况就很少了,但是实际业务中没办法缩短数据,一串json不可能分开发送
What did you see happen?
数据会有断开的情况
What did you expect to see?
希望不要断开
The text was updated successfully, but these errors were encountered: