Commit bbc362c3 by CaIon

fix: add nil check for Writer in FlushWriter function

parent ba6ed31a
......@@ -15,6 +15,9 @@ import (
)
func FlushWriter(c *gin.Context) error {
if c.Writer == nil {
return nil
}
if flusher, ok := c.Writer.(http.Flusher); ok {
flusher.Flush()
return nil
......@@ -28,14 +31,14 @@ func SetEventStreamHeaders(c *gin.Context) {
return
}
// 设置标志,表示头部已经设置过
c.Set("event_stream_headers_set", true)
c.Writer.Header().Set("Content-Type", "text/event-stream")
c.Writer.Header().Set("Cache-Control", "no-cache")
c.Writer.Header().Set("Connection", "keep-alive")
c.Writer.Header().Set("Transfer-Encoding", "chunked")
c.Writer.Header().Set("X-Accel-Buffering", "no")
// 设置标志,表示头部已经设置过
c.Set("event_stream_headers_set", true)
}
func ClaudeData(c *gin.Context, resp dto.ClaudeResponse) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment