v0.1.0

HTTP Probing

Last updated


This page explains how Monitor.Check() decides whether a site is online: URL normalization, when it switches from HEAD to GET, timeouts, and the online criteria.

URL Normalization


When the input URL does not start with http, https:// is prepended (internal/service/monitor.go:78).
InputActual request
example.comhttps://example.com
https://example.com/healthUnchanged
http://example.comUnchanged (requested over HTTP)

The normalized URL is written to list[].url in .webMonitor.json, and the watch list loads that value after a restart.

Request Flow


graph TB
    Start[Check url] --> Norm[Prepend https://]
    Norm --> Head[Send HEAD]
    Head -->|connection error or 404| Get[Send GET]
    Head -->|any other status| Judge
    Get --> Judge{Got a response?}
    Judge -->|Yes| SSL[CheckExpire reads certificate]
    SSL --> Code[Judge online by status code]
    Judge -->|No| Offline[Offline, Code = 0]
  1. graph TB
  2. Start[Check url] --> Norm[Prepend https://]
  3. Norm --> Head[Send HEAD]
  4. Head -->|connection error or 404| Get[Send GET]
  5. Head -->|any other status| Judge
  6. Get --> Judge{Got a response?}
  7. Judge -->|Yes| SSL[CheckExpire reads certificate]
  8. SSL --> Code[Judge online by status code]
  9. Judge -->|No| Offline[Offline, Code = 0]

ItemValue
First requestHEAD
Switch to GET whenHEAD hits a connection error (including timeout) or returns 404
Timeouthttp.Client.Timeout of 10 seconds, counted separately for HEAD and GET
RedirectsFollowed
Request headersUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36, Accept: */*, Connection: keep-alive

Only connection errors and 404 trigger GET. When a server rejects HEAD with 405 (Method Not Allowed) or any other 4xx / 5xx, the check does not retry with GET and marks the site offline.

Online Criteria


Resultonlinecode
Status code 200–399trueActual status code
Status code ≥ 400falseActual status code
Connection failure, timeout, DNS errorfalse0

duration records the total time of the check, including the GET retry after a failed HEAD and the SSL certificate connection that follows a response, and the table shows it in milliseconds.

When the SSL Check Runs


util.CheckExpire() reads the certificate only when the request got a response (any status code); on connection failure the SSL field is 0. See SSL Expiry for details.
中文