MCPcopy Create free account
hub / github.com/code-scan/Goal / setParams

Method setParams

Ghttp/post.go:56–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54 return h
55}
56func (h *Http) setParams() *Http {
57 if h.HttpRequest != nil && h.HttpBody != nil {
58 h.HttpRequest.Body = ioutil.NopCloser(h.HttpBody)
59 switch v := h.HttpBody.(type) {
60 case *bytes.Buffer:
61 h.HttpRequest.ContentLength = int64(v.Len())
62 buf := v.Bytes()
63 h.HttpRequest.GetBody = func() (io.ReadCloser, error) {
64 r := bytes.NewReader(buf)
65 return io.NopCloser(r), nil
66 }
67 case *bytes.Reader:
68 h.HttpRequest.ContentLength = int64(v.Len())
69 snapshot := *v
70 h.HttpRequest.GetBody = func() (io.ReadCloser, error) {
71 r := snapshot
72 return io.NopCloser(&r), nil
73 }
74 case *strings.Reader:
75 h.HttpRequest.ContentLength = int64(v.Len())
76 snapshot := *v
77 h.HttpRequest.GetBody = func() (io.ReadCloser, error) {
78 r := snapshot
79 return io.NopCloser(&r), nil
80 }
81 default:
82
83 }
84 }
85 return h
86}

Callers 3

SetPostValuesMethod · 0.95
SetPostJsonMethod · 0.95
SetPostStringMethod · 0.95

Calls 1

LenMethod · 0.45

Tested by

no test coverage detected