public boolean isOnline ( ) { LOG . debug ( "Checking online status for {} at {}" , getName ( ) , getURL ( ) ) ; try { return client . execute ( new HttpHead ( toURI ( getURL ( ) ) ) ) . getStatusLine ( ) . getStatusCode ( ) != 404 ; } catch ( Exception e ) { return false ; } }
This method will send HTTP HEAD request to the camera URL to check whether it s online or offline . It s online when this request succeed and it s offline if any exception occurs or response code is 404 Not Found .