Skip to content

Commit 4d596a2

Browse files
committed
Add comment for ASGI encoding spec and change to unicode_escape
1 parent 118f259 commit 4d596a2

File tree

1 file changed

+4
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi

1 file changed

+4
-1
lines changed

instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,4 +945,7 @@ def _decode_header_item(value):
945945
try:
946946
return value.decode("utf-8")
947947
except ValueError:
948-
return value.decode("latin-1")
948+
# ASGI header encoding specs, see:
949+
# - https://asgi.readthedocs.io/en/latest/specs/www.html#wsgi-encoding-differences (see: WSGI encoding differences)
950+
# - https://docs.python.org/3/library/codecs.html#text-encodings (see: Text Encodings)
951+
return value.decode("unicode_escape")

0 commit comments

Comments
 (0)