Feat: add http status and code from http cmd run

Signed-off-by: suxiang <704427617@qq.com>
This commit is contained in:
suxiang
2022-08-01 20:52:14 +08:00
parent 976d683185
commit 0b96b2e60a
+6 -3
View File
@@ -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
}