Concordium / concordium-node

The main concordium node implementation.
GNU Affero General Public License v3.0
45 stars 22 forks source link

Grpcweb response #1054

Closed lassemand closed 1 year ago

lassemand commented 1 year ago

Description

When not having grpcweb enabled, and requesting a resource under the path of a grpcweb resource, I expect a proper response like for example 404

Steps to Reproduce

Not having set CONCORDIUM_NODE_GRPC2_ENABLE_GRPC_WEB set to true and requesting

curl -v 'http://localhost:20000/concordium.v2.Queries/GetCryptographicParameters' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Origin: chrome-extension://nfolgkpbmebkjgdmgeohcmnlmodfcech/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: none' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  -H 'accept: application/grpc-web-text' \
  -H 'content-type: application/grpc-web-text' \
  -H 'grpc-timeout: 15000m' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'x-grpc-web: 1' \
  --data-raw 'AAAAAAISAA==' \
  --compressed

Expected Result

At the very least a proper status code. Ideally even a nice little message indicating that grpcweb endpoints are not enabled

Actual Result

* upload completely sent off: 12 out of 12 bytes
* Received HTTP/0.9 when not allowed
* Closing connection 0

Versions

abizjak commented 1 year ago

The issue is that curl will make a http1.1 request by default, and unless you enable grpc-web the server that is started will not support http1.1 since grpc goes over http2. You can force curl to use http2 by using --http2-prior-knowledge and then you'll get a status code 12 (UNIMPLEMENTED)

It would be weird to enable http1.1 just to support a nice error message in this context.

See also https://github.com/hyperium/hyper/issues/2378