MCPcopy Create free account
hub / github.com/acl-dev/acl / http_util_dump_url

Function http_util_dump_url

lib_protocol/src/http/http_util.c:375–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375int http_util_dump_url(const char *url, const char *dump)
376{
377 const char *myname = "http_util_dump_url";
378 HTTP_UTIL *http_util = http_util_req_new(url, "GET");
379 char buf[4096];
380 int ret;
381
382 if (http_util == NULL)
383 return (-1);
384 if (dump == NULL || *dump == 0) {
385 acl_msg_error("%s(%d): dump invalid", myname, __LINE__);
386 return (-1);
387 }
388
389 if (http_util_set_dump_file(http_util, dump) < 0) {
390 acl_msg_error("%s(%d): open dump file(%s) error(%s)",
391 myname, __LINE__, dump, acl_last_serror());
392 http_util_free(http_util);
393 return (-1);
394 }
395
396 if (http_util_req_open(http_util) < 0) {
397 acl_msg_error("%s(%d): open url(%s) error(%s)",
398 myname, __LINE__, url, acl_last_serror());
399 http_util_free(http_util);
400 return (-1);
401 }
402
403 if (http_util_get_res_hdr(http_util) < 0) {
404 acl_msg_error("%s(%d): url(%s)'s respond error",
405 myname, __LINE__, url);
406 http_util_free(http_util);
407 return (-1);
408 }
409
410 while (1) {
411 if (http_util_get_res_body(http_util, buf, sizeof(buf)) <= 0)
412 break;
413 }
414
415 ret = http_util->res_body_dlen;
416 http_util_free(http_util);
417 return (ret);
418}
419
420int http_util_dump_url_to_stream(const char *url, ACL_VSTREAM *stream)
421{

Callers 1

get_urlFunction · 0.85

Calls 8

http_util_req_newFunction · 0.85
acl_msg_errorFunction · 0.85
http_util_set_dump_fileFunction · 0.85
acl_last_serrorFunction · 0.85
http_util_freeFunction · 0.85
http_util_req_openFunction · 0.85
http_util_get_res_hdrFunction · 0.85
http_util_get_res_bodyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…