Skip to content

Commit 1c63584

Browse files
committed
revert change to http request body
1 parent f4a702d commit 1c63584

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

kite-service/internal/api/session/middleware.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package session
22

33
import (
4+
"fmt"
5+
46
"github.com/kitecloud/kite/kite-service/internal/api/handler"
57
)
68

79
func (m *SessionManager) RequireSession(next handler.HandlerFunc) handler.HandlerFunc {
810
return func(c *handler.Context) error {
911
session, err := m.Session(c)
1012
if err != nil {
11-
return err
13+
return fmt.Errorf("failed to get session: %w", err)
1214
}
1315

1416
if session == nil {

kite-service/pkg/eval/ctx.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ func (s SnowflakeEnv) String() string {
427427

428428
type HTTPResponseEnv struct {
429429
resp *http.Response
430-
body []byte
431430

432431
Status string `expr:"status" json:"status"`
433432
StatusCode int `expr:"status_code" json:"status_code"`
@@ -440,19 +439,13 @@ func NewHTTPResponseEnv(resp *http.Response) *HTTPResponseEnv {
440439

441440
Status: resp.Status,
442441
StatusCode: resp.StatusCode,
443-
}
444-
res.BodyFunc = func() (string, error) {
445-
if res.body != nil {
446-
return string(res.body), nil
447-
}
448-
449-
body, err := io.ReadAll(resp.Body)
450-
if err != nil {
451-
return "", err
452-
}
453-
454-
res.body = body
455-
return string(body), nil
442+
BodyFunc: func() (string, error) {
443+
body, err := io.ReadAll(resp.Body)
444+
if err != nil {
445+
return "", err
446+
}
447+
return string(body), nil
448+
},
456449
}
457450

458451
return res

0 commit comments

Comments
 (0)