Skip to content

Correct status trailers to be strs in unary ASGI responses.#68

Open
willjschmitt wants to merge 1 commit intopublic:masterfrom
willjschmitt:01-12-correct_status_trailers_to_be_str_s_in_unary_asgi_responses
Open

Correct status trailers to be strs in unary ASGI responses.#68
willjschmitt wants to merge 1 commit intopublic:masterfrom
willjschmitt:01-12-correct_status_trailers_to_be_str_s_in_unary_asgi_responses

Conversation

@willjschmitt
Copy link

pack_trailers expects a list of str pairs in contrast to ASGI headers, which are bytes pairs. When they are passed to pack_trailers as bytes pairs, they are serialized as their bytes repr, which ends up as a string "b'grpc-status' and "b'grpc-message'".

It might be more desirable to unify with the ASGI spec and use bytes-pairs, but that would change the trailers pattern more in the implementation, such as deserialized counterparts. This ultimately is the smallest incremental change, which ensures trailers are written out properly and in the succesful case of unary requests, clients can decode the OK status successfully. WSGI and streaming ASGI trailer writing handled this right already.

Fixes #67

`pack_trailers` expects a list of `str` pairs in contrast to ASGI
headers, which are `bytes` pairs. When they are passed to
`pack_trailers` as `bytes` pairs, they are serialized as their bytes
`repr`, which ends up as a string `"b'grpc-status'` and
`"b'grpc-message'"`.

It might be more desirable to unify with the ASGI spec and use
bytes-pairs, but that would change the trailers pattern more in the
implementation, such as deserialized counterparts. This ultimately is
the smallest incremental change, which ensures trailers are written out
properly and in the succesful case of unary requests, clients can decode
the OK status successfully. WSGI and streaming ASGI trailer writing
handled this right already.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASGI unary response trailers serialize byte-string representation instead of actual header keys/values

1 participant