File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -427,26 +427,35 @@ func (s SnowflakeEnv) String() string {
427427
428428type HTTPResponseEnv struct {
429429 resp * http.Response
430+ body []byte
430431
431432 Status string `expr:"status" json:"status"`
432433 StatusCode int `expr:"status_code" json:"status_code"`
433434 BodyFunc func () (string , error ) `expr:"body" json:"-"`
434435}
435436
436437func NewHTTPResponseEnv (resp * http.Response ) * HTTPResponseEnv {
437- return & HTTPResponseEnv {
438+ res := & HTTPResponseEnv {
438439 resp : resp ,
439440
440441 Status : resp .Status ,
441442 StatusCode : resp .StatusCode ,
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- },
449443 }
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
456+ }
457+
458+ return res
450459}
451460
452461func (h HTTPResponseEnv ) String () string {
You can’t perform that action at this time.
0 commit comments