{"id":17059858,"url":"https://github.com/natural/http-simulator","last_synced_at":"2025-07-29T16:42:14.570Z","repository":{"id":136983506,"uuid":"105938533","full_name":"natural/http-simulator","owner":"natural","description":"Simulate HTTP responses with HTTP requests.","archived":false,"fork":false,"pushed_at":"2017-10-05T23:53:10.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T07:44:58.713Z","etag":null,"topics":["http","python","testing"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/natural.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-05T20:44:48.000Z","updated_at":"2017-10-09T13:05:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d5a3bd6-e3de-4023-85e1-4ca067a24972","html_url":"https://github.com/natural/http-simulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/natural/http-simulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natural%2Fhttp-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natural%2Fhttp-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natural%2Fhttp-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natural%2Fhttp-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/natural","download_url":"https://codeload.github.com/natural/http-simulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/natural%2Fhttp-simulator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267718748,"owners_count":24133462,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["http","python","testing"],"created_at":"2024-10-14T10:35:34.570Z","updated_at":"2025-07-29T16:42:14.489Z","avatar_url":"https://github.com/natural.png","language":"Python","readme":"# http-simulator\n\nSimulate HTTP responses with HTTP requests.\n\n\n## Synopsis\n\n```sh\n$ # start the simulator\n$ http-simulator \u0026\n\n# tell it what to serve\n$ http --json GET :8000/breakfast X-Simulator-Set:status=415 eggs=green ham=spam\nHTTP/1.0 205 Reset Content\n...\n\n# make http requests\n$ http GET :8000/breakfast\nHTTP/1.0 415 Unsupported Media Type\nContent-Type: application/json\n...\n{\n\t\"eggs\": \"green\",\n\t\"ham\": \"spam\"\n}\n```\n\n## Usage\n\n```\nusage: http-simulator [-h] [-b BIND] [-d DB] [-q] [-r] [-w]\n\nServe HTTP responses simulated with HTTP requests.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -b BIND, --bind BIND  bind to host:port (default: *:8000)\n  -d DB, --database DB  sqlite3 database filename (default: :memory:)\n  -q, --quiet           quiet output (default: False)\n  -r, --read-only       do not write to the database (default: False)\n  -w, --watch           watch the script for changes and restart (default: False)\n```\n\n## Install\n\nFor one-shot execution, e.g., in a container:\n\n```sh\n$ curl https://raw.githubusercontent.com/natural/http-simulator/master/http-simulator | python3\n```\n\nFor local installation:\n\n```sh\n$ curl -Lo http-simulator https://raw.githubusercontent.com/natural/http-simulator/master/http-simulator \u0026\u0026 chmod +x http-simulator \u0026\u0026 sudo mv http-simulator /usr/local/bin/\n$ http-simulator\n```\n\n## Operation\n\nOnce the server is running, you configure the URLs it serves by\nsending it requests with the `X-Simulator-Set` header.  For example:\n\n```sh\n$ http GET :8000/path/to/test X-Simulator-Set:status=302 Location:/some/other/path/to/check\nHTTP/1.0 205 Reset Content\nDate: Thu, 05 Oct 2017 20:55:28 GMT\nServer: BaseHTTP/0.6 Python/3.6.2\n```\n\nAfter a URL is set, you can make requests to it (without the x-simulator headers):\n\n```sh\n$ http GET :8000/path/to/test\nHTTP/1.0 302 Found\nDate: Thu, 05 Oct 2017 20:55:39 GMT\nLocation: /some/other/path/to/check\nServer: BaseHTTP/0.6 Python/3.6.2\n```\n\n## Details\n\nThe server responds to requests as follows:\n\n1.  If the request contains a `X-Simulator-Set` header, update the\n\trouting table with the contents of the header, and then respond with `205 Reset Content`.\n\n2.  Otherwise query the routing table with the HTTP request method,\n\tpath (and in the future, query string).  Respond with the status,\n\theaders, and body from the routing table.\n\n3.  Otherwise respond with `404 Not Found`\n\n### The `X-Simulator-Set` Header\n\nWhen the `X-Simulator-Set` should contain key-value pairs, separated via `=`.  Recognized keys:\n\n* `status`: value used as the response status code; default `200`\n\n* `headers`: name of header to copy, or name of known preset; default\n  is preset `default`.  May be repeated, and if so, results are\n  cumulative.  Presets:\n\n  * `all`: all request headers are saved\n  * `all-nox`: all non-extension (`X-*`) headers are saved\n  * `default`: only `Content-Type`, `Content-Length`, and `Location` headers are saved\n  * `xs`: only extension headers (`X-*`) are saved\n\n\n### Future Work\n\n* needs a test\n* match by query string isn't yet supported\n* map method ANY to create routes for GET, PUT, POST, etc.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatural%2Fhttp-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatural%2Fhttp-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatural%2Fhttp-simulator/lists"}