{"id":15390252,"url":"https://github.com/gajus/waitehr","last_synced_at":"2025-04-15T21:27:30.748Z","repository":{"id":39651045,"uuid":"496778610","full_name":"gajus/waitehr","owner":"gajus","description":"Waits for HTTP response and retries request until the expected response is received.","archived":false,"fork":false,"pushed_at":"2023-01-04T17:43:09.000Z","size":251,"stargazers_count":37,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-08T12:50:33.888Z","etag":null,"topics":["cli","http"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gajus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-26T21:37:04.000Z","updated_at":"2024-09-20T14:45:08.000Z","dependencies_parsed_at":"2023-02-02T19:31:27.459Z","dependency_job_id":null,"html_url":"https://github.com/gajus/waitehr","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fwaitehr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fwaitehr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fwaitehr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fwaitehr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gajus","download_url":"https://codeload.github.com/gajus/waitehr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233690725,"owners_count":18714829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","http"],"created_at":"2024-10-01T15:05:05.789Z","updated_at":"2025-01-13T04:19:17.853Z","avatar_url":"https://github.com/gajus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Waits for expected HTTP response\n\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social\u0026label=Follow)](https://twitter.com/kuizinas)\n\n`waitehr` (wait [for] expected HTTP response) is a CLI program that waits for HTTP response and retries request until the expected response is received.\n\n## Motivation\n\nWe needed a reliable utility for checking when a deployment goes live in a CI/CD pipeline.\n\n### Why not just use Bash/curl/...?\n\n\u003e You should be able to do this with curl and a simple bash script.\n\nYou could achieve something similar to this with bash:\n\n```bash\nwhile curl https://gajus.com/ | grep -q Gajus; do sleep 1; done\n```\n\nHowever, by the time you add:\n\n- routine timeout\n- request timeout\n- follow redirects\n- max redirects\n- success threshold\n\nIt is going to be a pretty hefty script, and if everyone (with their varying experience of using Bash) were to write that script adhoc, it is likely to be error prone. It is for this reason that it makes sense to use a well tested utility that does it well.\n\n## Install\n\n```bash\nnpm install waitehr --global\n```\n\n## Usage\n\n```bash\nwaitehr \u003curl\u003e [options]\n\n# Waits for response with status code 200.\nwaitehr https://gajus.com/\n\n# Retries request at most once every 5 seconds (default: 1).\nwaitehr https://gajus.com/ --interval 5\n\n# Waits at most 120 seconds (default: 60).\nwaitehr https://gajus.com/ --timeout 60\n\n# Waits for response with status code 200 or 404.\nwaitehr https://gajus.com/ --status-code 200 404\n\n# Waits for response that contains \"foo\" and \"bar\".\nwaitehr https://gajus.com/ --contains \"foo\" \"bar\"\n\n# Waits for response that has a specific header.\nwaitehr https://gajus.com/ --has-header \"foo: bar\"\n\n# Adds custom headers to the request.\nwaitehr https://gajus.com/ --header \"Accepts: text/html\" \"Authorization: Bearer\nfkd9afsda9k\"\n\n\nOptions:\n  --help               Show help                                       [boolean]\n  --version            Show version number                             [boolean]\n  --contains           Expected string(s). If multiple strings are provided,\n                       then all of them must be contained in the response.\n                                                                         [array]\n  --follow-redirect    Defines if redirect responses should be followed\n                       automatically.                                  [boolean]\n  --has-header         Expected header(s). If multiple headers are provided,\n                       then all of them must be contained in the response.\n                                                                         [array]\n  --header             Extra header to include in the request when sending HTTP\n                       to a server. \u003cHeader Key\u003e: \u003cHeader Value\u003e.        [array]\n  --initial-delay      How many seconds to delay the first request.\n                                                           [number] [default: 0]\n  --interval           How many seconds to sleep between every attempt.\n                                                           [number] [default: 1]\n  --max-redirects      If exceeded, the request will be aborted.\n                                                           [number] [default: 5]\n  --prepend-time       Prepends time to each check output.\n                                                       [boolean] [default: true]\n  --quiet              Disables any output.           [boolean] [default: false]\n  --request-timeout    How many seconds to wait for individual requests to\n                       complete. If exceeded, requests are aborted and a new\n                       request is started.                 [number] [default: 5]\n  --status-codes       Expected status code(s). If multiple status codes are\n                       provided, then either will be accepted as valid.\n                                                        [array] [default: \"200\"]\n  --success-threshold  Minimum consecutive successes for the probe to be\n                       considered successful.              [number] [default: 1]\n  --timeout            How many seconds to wait before giving up.  [default: 60]\n```\n\n## Alternatives\n\n- [check_http](https://www.monitoring-plugins.org/doc/man/check_http.html) – Nagios plugin with equivalent functionality.\n- [httping](https://www.vanheusden.com/httping/) – utility for measuring latency and throughput of a webserver with limited some assertion capabilities.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fwaitehr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgajus%2Fwaitehr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fwaitehr/lists"}