Open jaw111 opened 1 year ago
Hi @jaw111, thanks for reporting this.
I think in your example the accept
header is present but blank. You are probably right and probably 400 Bad Request
would be the most suitable response code?
Hi @c-martinez,
If you look at the verbose output, you see there is no accept
header in the request.
Setting the header with an empty value will make curl remove the header, not just send a header with a blank value.
@c-martinez the 406 Not Acceptable
response status code would be a more meaningful response than 400 Bad Request
.
Though https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406 suggests:
In practice, this error is very rarely used. Instead of responding using this error code, which would be cryptic for the end user and difficult to fix, servers ignore the relevant header and serve an actual page to the user. It is assumed that even if the user won't be completely happy, they will prefer this to an error code.
To reproduce the error, use this curl command:
The verbose output showing request and response headers:
Running a local instance of grlc, I see these kind of errors in the application logs:
If the
accept
header is expected/required, it'd be more appropriate to return a 4XX response code.Otherwise, if no
accept
header is present, then serve JSON by default.