| 34 | } |
| 35 | |
| 36 | void 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 | } |
no test coverage detected