mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
datasette --get --headers option, closes #2578
This commit is contained in:
parent
9f74dc22a8
commit
ce464da34b
3 changed files with 23 additions and 1 deletions
|
|
@ -445,7 +445,7 @@ def uninstall(packages, yes):
|
|||
@click.option(
|
||||
"--headers",
|
||||
is_flag=True,
|
||||
help="Include HTTP headers in --get output (requires --get)",
|
||||
help="Include HTTP headers in --get output",
|
||||
)
|
||||
@click.option(
|
||||
"--token",
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ Once started you can access it at ``http://localhost:8001``
|
|||
the root user
|
||||
--get TEXT Run an HTTP GET request against this path,
|
||||
print results and exit
|
||||
--headers Include HTTP headers in --get output
|
||||
--token TEXT API token to send with --get requests
|
||||
--actor TEXT Actor to use for --get requests (JSON string)
|
||||
--version-note TEXT Additional note to show on /-/versions
|
||||
|
|
|
|||
|
|
@ -52,6 +52,27 @@ def test_serve_with_get(tmp_path_factory):
|
|||
pm.unregister(to_unregister)
|
||||
|
||||
|
||||
def test_serve_with_get_headers():
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
"serve",
|
||||
"--memory",
|
||||
"--get",
|
||||
"/_memory/",
|
||||
"--headers",
|
||||
],
|
||||
)
|
||||
# exit_code is 1 because it wasn't a 200 response
|
||||
assert result.exit_code == 1, result.output
|
||||
assert result.output == (
|
||||
"HTTP/1.1 302\n"
|
||||
"location: /_memory\n"
|
||||
"content-type: text/html; charset=utf-8\n"
|
||||
)
|
||||
|
||||
|
||||
def test_serve_with_get_and_token():
|
||||
runner = CliRunner()
|
||||
result1 = runner.invoke(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue