Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "grpc-status" header #50

Open
ErikUniformAgri opened this issue May 31, 2023 · 0 comments
Open

Missing "grpc-status" header #50

ErikUniformAgri opened this issue May 31, 2023 · 0 comments

Comments

@ErikUniformAgri
Copy link

ErikUniformAgri commented May 31, 2023

I am using TgoHttpClient with http2 as a client to connect to a gRPC server.
The connection works fine, but if I do a a bad request there is no error. The statuscode is still 200.
gRPC uses a grpc-status and grpc-message header, but I am not able to use this header since it is filtered out for some reason.

I found that if I change frame.headers.cat = NGHTTP2_HCAT_RESPONSE to (frame.headers.cat in [NGHTTP2_HCAT_RESPONSE,3]) I do get the correct headers. on https://nghttp2.org/documentation/enums.html#c.nghttp2_headers_category I found what 3 means and
on https://github.com/ultraware/DelphiGrpc/tree/master/ngHttp2 I found there is constant declared for this.

function TgoHttpClient.nghttp2_on_header_callback(session: pnghttp2_session; const frame: pnghttp2_frame;
  const name: puint8; namelen: size_t; const value: puint8; valuelen: size_t;
  flags: uint8; user_data: Pointer): Integer;
var
  AName, AValue: String;
  Index: Integer;
begin
  {$IFDEF LOGGING}
  grLog('on_header_callback');
  {$ENDIF}
  if frame.hd.&type = _NGHTTP2_HEADERS then
    if (frame.headers.cat in [NGHTTP2_HCAT_RESPONSE,3]) then
    begin
      .....
    end;
end;

Example from https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md.

HEADERS (flags = END_HEADERS)
:status = 200
grpc-encoding = gzip
content-type = application/grpc+proto

DATA
<Length-Prefixed Message>

HEADERS (flags = END_STREAM, END_HEADERS)
grpc-status = 0 # OK
trace-proto-bin = jher831yy13JHy3hc

Is the solution to update https://github.com/grijjy/DelphiRemotePushSender with https://github.com/ultraware/DelphiGrpc/tree/master/ngHttp2 and use NGHTTP2_HCAT_HEADERS instead of the hardcoded 3 ?

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

No branches or pull requests

1 participant