mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-17 16:06:38 +08:00
fix: try to fix curl: (18)
This commit is contained in:
parent
c4b3d3a975
commit
d9344d79cf
@ -213,9 +213,17 @@ func OpenaiHandler(c *gin.Context, resp *http.Response, promptTokens int, model
|
|||||||
// And then we will have to send an error response, but in this case, the header has already been set.
|
// And then we will have to send an error response, but in this case, the header has already been set.
|
||||||
// So the httpClient will be confused by the response.
|
// So the httpClient will be confused by the response.
|
||||||
// For example, Postman will report error, and we cannot check the response at all.
|
// For example, Postman will report error, and we cannot check the response at all.
|
||||||
|
// Copy headers
|
||||||
for k, v := range resp.Header {
|
for k, v := range resp.Header {
|
||||||
c.Writer.Header().Set(k, v[0])
|
// 删除任何现有的相同头部,以防止重复添加头部
|
||||||
|
c.Writer.Header().Del(k)
|
||||||
|
for _, vv := range v {
|
||||||
|
c.Writer.Header().Add(k, vv)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// reset content length
|
||||||
|
c.Writer.Header().Del("Content-Length")
|
||||||
|
c.Writer.Header().Set("Content-Length", fmt.Sprintf("%d", len(doResponseBody)))
|
||||||
c.Writer.WriteHeader(resp.StatusCode)
|
c.Writer.WriteHeader(resp.StatusCode)
|
||||||
_, err = io.Copy(c.Writer, resp.Body)
|
_, err = io.Copy(c.Writer, resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user