()
| 54 | return h |
| 55 | } |
| 56 | func (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 | } |
no test coverage detected