(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest)
| 1658 | } |
| 1659 | |
| 1660 | func answerHeadPing(logf logger.Logf, c *http.Client, pr *tailcfg.PingRequest) { |
| 1661 | ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) |
| 1662 | defer cancel() |
| 1663 | |
| 1664 | req, err := http.NewRequestWithContext(ctx, "HEAD", pr.URL, nil) |
| 1665 | if err != nil { |
| 1666 | logf("answerHeadPing: NewRequestWithContext: %v", err) |
| 1667 | return |
| 1668 | } |
| 1669 | if pr.Log { |
| 1670 | logf("answerHeadPing: sending HEAD ping to %v ...", pr.URL) |
| 1671 | } |
| 1672 | t0 := clock.Now() |
| 1673 | _, err = c.Do(req) |
| 1674 | d := clock.Since(t0).Round(time.Millisecond) |
| 1675 | if err != nil { |
| 1676 | logf("answerHeadPing error: %v to %v (after %v)", err, pr.URL, d) |
| 1677 | } else if pr.Log { |
| 1678 | logf("answerHeadPing complete to %v (after %v)", pr.URL, d) |
| 1679 | } |
| 1680 | } |
| 1681 | |
| 1682 | // sleepAsRequest implements the sleep for a tailcfg.Debug message requesting |
| 1683 | // that the client sleep. The complication is that while we're sleeping (if for |
no test coverage detected
searching dependent graphs…