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

Method sio_check_http

lib_acl_cpp/samples/connect_manager/check_sync.cpp:36–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void check_sync::sio_check_http(acl::check_client& checker,
37 acl::socket_stream& conn)
38{
39 acl::http_request req(&conn, 60, false);
40 acl::http_header& hdr = req.request_header();
41
42 acl::string ctype("text/plain; charset=gbk");
43 hdr.set_url("/").set_content_type("text/plain; charset=gbk");
44 if (req.request(NULL, 0) == false)
45 {
46 printf(">>> send request error\r\n");
47 checker.set_alive(false);
48 return;
49 }
50
51 acl::string buf;
52 if (req.get_body(buf) == false)
53 {
54 printf(">>> HTTP get_body ERROR, SERVER: %s <<<\r\n",
55 checker.get_addr());
56 checker.set_alive(false);
57 return;
58 }
59
60 int status = req.http_status();
61 if (status == 200 || status == 404)
62 {
63 printf(">>> SIO_CHECK HTTP SERVER(%s) OK: %d <<<\r\n",
64 checker.get_addr(), status);
65 checker.set_alive(true);
66 }
67 else
68 {
69 printf(">>> SIO_CHECK HTTP SERVER(%s) ERROR: %d <<<\r\n",
70 checker.get_addr(), status);
71 checker.set_alive(false);
72 }
73}

Callers 1

sio_checkMethod · 0.80

Calls 7

request_headerMethod · 0.80
set_content_typeMethod · 0.80
http_statusMethod · 0.80
requestMethod · 0.45
set_aliveMethod · 0.45
get_bodyMethod · 0.45
get_addrMethod · 0.45

Tested by

no test coverage detected