]> git.kaiwu.me - nginx.git/commit
gRPC: special handling of "trailer only" responses.
authorMaxim Dounin <mdounin@mdounin.ru>
Sat, 17 Mar 2018 20:04:26 +0000 (23:04 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Sat, 17 Mar 2018 20:04:26 +0000 (23:04 +0300)
commit6559a420134b0f52ce2d4f147bdd92269ad5f677
tree31489b3932e6aad60824b7a4cf306e66aa545e8a
parent6a0d9e5b2d9274e5ac5059a674763f19c2731b11
gRPC: special handling of "trailer only" responses.

The gRPC protocol makes a distinction between HEADERS frame with
the END_STREAM flag set, and a HEADERS frame followed by an empty
DATA frame with the END_STREAM flag.  The latter is not permitted,
and results in errors not being propagated through nginx.  Instead,
gRPC clients complain that "server closed the stream without sending
trailers" (seen in grpc-go) or "13: Received RST_STREAM with error
code 2" (seen in grpc-c).

To fix this, nginx now returns HEADERS with the END_STREAM flag if
the response length is known to be 0, and we are not expecting
any trailer headers to be added.  And the response length is
explicitly set to 0 in the gRPC proxy if we see initial HEADERS frame
with the END_STREAM flag set.
src/http/modules/ngx_http_grpc_module.c
src/http/v2/ngx_http_v2_filter_module.c