Skip to content

Commit 7b87880

Browse files
committed
fix(heartbeat): 修复心跳响应头设置逻辑
- 修改心跳响应的Content-Type头部设置方式,确保使用正确的Writer方法。 - 在响应中添加HTTP状态码200,以明确表示请求成功。
1 parent 17815fc commit 7b87880

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

relay/relay_util/heartbeat.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package relay_util
33
import (
44
"context"
55
"fmt"
6+
"net/http"
67
"one-api/common/logger"
78
"one-api/common/requester"
89
"sync/atomic"
@@ -72,7 +73,8 @@ func (h *Heartbeat) writeHeader() bool {
7273
if h.isStream {
7374
requester.SetEventStreamHeaders(h.c)
7475
} else {
75-
h.c.Header("Content-Type", "application/json")
76+
h.c.Writer.Header().Set("Content-Type", "application/json")
77+
h.c.Writer.WriteHeader(http.StatusOK)
7678
}
7779
return true
7880
}

0 commit comments

Comments
 (0)