From 0b96b2e60ae9a7a8e7c2d575ec88bb5efdfca037 Mon Sep 17 00:00:00 2001 From: suxiang <704427617@qq.com> Date: Mon, 1 Aug 2022 20:52:14 +0800 Subject: [PATCH] Feat: add http status and code from http cmd run Signed-off-by: suxiang <704427617@qq.com> --- pkg/builtin/http/http.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/builtin/http/http.go b/pkg/builtin/http/http.go index 01f8c7b3d..3f79995be 100644 --- a/pkg/builtin/http/http.go +++ b/pkg/builtin/http/http.go @@ -22,6 +22,7 @@ import ( "crypto/x509" "io" "net/http" + "strconv" "time" "cuelang.org/go/cue" @@ -128,9 +129,11 @@ func (c *HTTPCmd) Run(meta *registry.Meta) (res interface{}, err error) { b, err := io.ReadAll(resp.Body) // parse response body and headers return map[string]interface{}{ - "body": string(b), - "header": resp.Header, - "trailer": resp.Trailer, + "body": string(b), + "header": resp.Header, + "trailer": resp.Trailer, + "status": resp.Status, + "status_code": strconv.Itoa(resp.StatusCode), }, err }