Skip to content

Commit

Permalink
fix: handle rep.text responses (needs tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
iFergal committed Jan 23, 2025
1 parent 0441be2 commit 3b080f8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/keria/core/authing.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def wrap(req, rep):

pubkey = pysodium.crypto_sign_pk_to_box_pk(ckever.verfers[0].raw)
raw = pysodium.crypto_box_seal(inner, pubkey)

rep.data = raw
rep.text = None

diger = coring.Diger(ser=raw, code=MtrDex.Blake3_256)
payload = dict(
Expand Down Expand Up @@ -234,5 +236,12 @@ def serializeResponse(protocol: str, response: falcon.Response):
f"{key}: {value}" for key, value in response.headers.items()
if key.lower() not in CORS_HEADERS
])
body = response.data.decode("utf-8") if response.data else ""

if response.text:
body = response.text.strip()
elif response.data:
body = response.data.decode("utf-8")
else:
body = ""

return f"{status_line}\r\n{headers}\r\n\r\n{body}"

0 comments on commit 3b080f8

Please sign in to comment.