Skip to content

Commit 01731c5

Browse files
committed
Fix plain request using localhost and default Accept header
Use SERVER_NAME="localhost" so URLs pass validation (fixes pageview tracking 500s), and default Accept to text/html so markdown pages return HTML instead of raw markdown. Fixes #56, fixes #57
1 parent ce7b95b commit 01731c5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

plain/plain/cli/request.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def request(
9292
raise SystemExit(1)
9393

9494
# Create test client
95-
client = Client()
95+
client = Client(SERVER_NAME="localhost")
9696

9797
# If user_id provided, force login
9898
if user_id:
@@ -114,8 +114,8 @@ def request(
114114
click.secho(f"Authentication error: {e}", fg="red", err=True)
115115
raise SystemExit(1)
116116

117-
# Parse additional headers
118-
header_dict = {}
117+
# Parse additional headers (default Accept to text/html)
118+
header_dict = {"Accept": "text/html"}
119119
for header in headers:
120120
if ":" in header:
121121
key, value = header.split(":", 1)
@@ -135,8 +135,7 @@ def request(
135135
kwargs: dict[str, Any] = {
136136
"follow": follow,
137137
}
138-
if header_dict:
139-
kwargs["headers"] = header_dict
138+
kwargs["headers"] = header_dict
140139

141140
if method in ("POST", "PUT", "PATCH") and data:
142141
kwargs["data"] = data

0 commit comments

Comments
 (0)