ethpandaops / checkpointz

An Ethereum beacon chain checkpoint sync provider
GNU General Public License v3.0
141 stars 31 forks source link

Support qvalue weighting in Accept headers #165

Closed nflaig closed 5 months ago

nflaig commented 6 months ago

At the moment, Checkpointz does not support q-factor weighting in Accept header values.

E.g. if a client sends a header like this

Accept: application/octet-stream;q=1,application/json;q=0.9

Checkpointz should handle this as prefer sending ssz response and if not suppored fall back to json and if that is not supported as well it should return a 406 status code.

The current behavior is that it assumes the client requested json data and it results in the following response for getStateV2

unsupported content-type: application/json

And it returns a 415 status code (406 would be more correct).

Ideally, should follow RFC-9110 for Accept header handling.

We have a bunch of test cases in Lodestar which might help to test the implementation, see acceptHeader.test.ts