(method, url string, param, header map[string]string, reqData []byte)
| 151 | } |
| 152 | |
| 153 | func (c *MetaHttpClient) httpRequest(method, url string, param, header map[string]string, reqData []byte) (resp *http.Response, err error) { |
| 154 | client := http.DefaultClient |
| 155 | reader := bytes.NewReader(reqData) |
| 156 | client.Timeout = requestTimeout |
| 157 | var req *http.Request |
| 158 | fullUrl := c.mergeRequestUrl(url, param) |
| 159 | log.LogDebugf("httpRequest: merge request url: method(%v) url(%v) bodyLength[%v].", method, fullUrl, len(reqData)) |
| 160 | if req, err = http.NewRequest(method, fullUrl, reader); err != nil { |
| 161 | return |
| 162 | } |
| 163 | req.Header.Set("Content-Type", "application/json") |
| 164 | req.Header.Set("Connection", "close") |
| 165 | for k, v := range header { |
| 166 | req.Header.Set(k, v) |
| 167 | } |
| 168 | resp, err = client.Do(req) |
| 169 | return |
| 170 | } |
| 171 | |
| 172 | func (c *MetaHttpClient) mergeRequestUrl(url string, params map[string]string) string { |
| 173 | if len(params) > 0 { |
no test coverage detected