Browse Source

Merge pull request #36 from zonito/patch-1

Add healthcheck UA to inform server about identity
pull/40/head
Pēteris Caune 9 years ago
parent
commit
45b8f00edf
2 changed files with 5 additions and 2 deletions
  1. +2
    -1
      hc/api/models.py
  2. +3
    -1
      hc/api/tests/test_notify.py

+ 2
- 1
hc/api/models.py View File

@ -139,7 +139,8 @@ class Channel(models.Model):
n.save()
elif self.kind == "webhook" and check.status == "down":
try:
r = requests.get(self.value, timeout=5)
headers = {"User-Agent": "healthchecks.io"}
r = requests.get(self.value, timeout=5, headers=headers)
n.status = r.status_code
except requests.exceptions.Timeout:
# Well, we tried


+ 3
- 1
hc/api/tests/test_notify.py View File

@ -26,7 +26,9 @@ class NotifyTestCase(BaseTestCase):
mock_get.return_value.status_code = 200
self.channel.notify(self.check)
mock_get.assert_called_with(u"http://example", timeout=5)
mock_get.assert_called_with(
u"http://example", headers={"User-Agent": "healthchecks.io"},
timeout=5)
@patch("hc.api.models.requests.get", side_effect=ReadTimeout)
def test_webhooks_handle_timeouts(self, mock_get):


Loading…
Cancel
Save