mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
_header_x now defaults to empty string
Prior to this a request to e.g. https://latest.datasette.io/fixtures/magic_parameters which did not include a User-Agent header would trigger a 500 error.
This commit is contained in:
parent
2115d7e345
commit
9ac6292614
2 changed files with 2 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ import time
|
||||||
def header(key, request):
|
def header(key, request):
|
||||||
key = key.replace("_", "-").encode("utf-8")
|
key = key.replace("_", "-").encode("utf-8")
|
||||||
headers_dict = dict(request.scope["headers"])
|
headers_dict = dict(request.scope["headers"])
|
||||||
return headers_dict[key].decode("utf-8")
|
return headers_dict.get(key, b"").decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
def actor(key, request):
|
def actor(key, request):
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ def magic_parameters_client():
|
||||||
[
|
[
|
||||||
("_actor_id", "root"),
|
("_actor_id", "root"),
|
||||||
("_header_host", "localhost"),
|
("_header_host", "localhost"),
|
||||||
|
("_header_not_a_thing", ""),
|
||||||
("_cookie_foo", "bar"),
|
("_cookie_foo", "bar"),
|
||||||
("_now_epoch", r"^\d+$"),
|
("_now_epoch", r"^\d+$"),
|
||||||
("_now_date_utc", r"^\d{4}-\d{2}-\d{2}$"),
|
("_now_date_utc", r"^\d{4}-\d{2}-\d{2}$"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue