MCPcopy Index your code
hub / github.com/cortexlabs/cortex / makeRequest

Function makeRequest

dev/load.go:266–313  ·  view source on GitHub ↗
(url string, jsonBytes []byte)

Source from the content-addressed store, hash-verified

264}
265
266func 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
315func mustReadJSONBytes(jsonPath string) []byte {
316 jsonBytes, err := files.ReadFileBytes(jsonPath)

Callers 2

makeRequestLoopFunction · 0.85

Calls 4

SppgFunction · 0.92
SetMethod · 0.80
ErrorMethod · 0.80
PrintMethod · 0.45

Tested by

no test coverage detected