(url string, jsonBytes []byte)
| 264 | } |
| 265 | |
| 266 | func makeRequest(url string, jsonBytes []byte) { |
| 267 | request, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonBytes)) |
| 268 | if err != nil { |
| 269 | fmt.Print("\n" + debug.Sppg(err)) |
| 270 | return |
| 271 | } |
| 272 | |
| 273 | request.Header.Set("Content-Type", "application/json") |
| 274 | |
| 275 | _requestCount.Inc() |
| 276 | |
| 277 | response, err := _client.Do(request) |
| 278 | if err != nil { |
| 279 | _goErrCount.Inc() |
| 280 | if _printGoErrors { |
| 281 | fmt.Print("\n" + debug.Sppg(err)) |
| 282 | } |
| 283 | return |
| 284 | } |
| 285 | |
| 286 | body, bodyReadErr := ioutil.ReadAll(response.Body) |
| 287 | response.Body.Close() |
| 288 | |
| 289 | if response.StatusCode == 200 { |
| 290 | _successCount.Inc() |
| 291 | } else { |
| 292 | _httpErrCount.Inc() |
| 293 | if _printHTTPErrors { |
| 294 | if bodyReadErr == nil { |
| 295 | fmt.Printf("\nstatus code: %d; body: %s\n", response.StatusCode, string(body)) |
| 296 | } else { |
| 297 | fmt.Printf("\nstatus code: %d; error reading body: %s\n", response.StatusCode, bodyReadErr.Error()) |
| 298 | } |
| 299 | return |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | if _printSuccessDots { |
| 304 | fmt.Print(".") |
| 305 | } |
| 306 | if _printBody { |
| 307 | bodyStr := string(body) |
| 308 | if bodyStr == "" { |
| 309 | bodyStr = "(no body)" |
| 310 | } |
| 311 | fmt.Print(bodyStr) |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | func mustReadJSONBytes(jsonPath string) []byte { |
| 316 | jsonBytes, err := files.ReadFileBytes(jsonPath) |
no test coverage detected