/* * SIPB service monitor: www module * * Nickolai Zeldovich * February 2002 */ #include #include #include "sipbmon.h" static rxx www_resp ("^HTTP/1.. 200 .*", "s"); static bool check_www_recv (struct sm_service *svc, str buf, bool eof) { if (www_resp.match (buf)) { service_up (svc); return false; } if (eof || buf.len() > 1024) { service_down (svc, "unexpected server response"); return false; } return true; } static void check_www_sent (struct sm_service *svc) { svc_read (svc, wrap (&check_www_recv, svc)); } void check_www (str url, struct sm_service *svc) { svc_write (svc, "GET " << url << " HTTP/1.0\r\n\r\n", wrap (&check_www_sent, svc)); }