We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
handling=strict
Prefer
Currently any unrecognized Prefer value will be accepted and ignored:
$ curl 'localhost:3000/projects' -H "Prefer: anything" -D - HTTP/1.1 200 OK [{"id":1,"name":"Windows 7","client_id":1}, {"id":2,"name":"Windows 10","client_id":1}, {"id":3,"name":"IOS","client_id":2}, {"id":4,"name":"OSX","client_id":2}, {"id":5,"name":"Orphan","client_id":null}]
This can give issues when you don't know what Prefer values a deployed PostgREST accepts (discussed on #2940 (comment)).
Support Prefer: handling=strict according https://www.rfc-editor.org/rfc/rfc7240.html#section-4.4. This would allow the client to check what Prefer values are accepted:
Prefer: handling=strict
$ curl 'localhost:3000/projects' -H "Prefer: handling=strict; anything" -D - HTTP/1.1 400 Bad Request
Using Prefer: handling=lenient would just accept and ignore the Prefer, as we've always done.
Prefer: handling=lenient
The logic that filters the accepted Prefers is currently on the Response module.
postgrest/src/PostgREST/Response.hs
Line 73 in 8d3c9f8
Line 101 in 8d3c9f8
It'd be better centralized at the Plan module. There we can fail and respond with an error.
The text was updated successfully, but these errors were encountered:
@steve-chavez In which module should I write tests for this feature? Or maybe should I create a new test module for this feature?
Sorry, something went wrong.
@taimoorzaeem A new test module seems fine, maybe PreferencesSpec
PreferencesSpec
(we might move all the Prefer tests there later on)
Successfully merging a pull request may close this issue.
Problem
Currently any unrecognized
Prefer
value will be accepted and ignored:This can give issues when you don't know what
Prefer
values a deployed PostgREST accepts (discussed on #2940 (comment)).Solution
Support
Prefer: handling=strict
according https://www.rfc-editor.org/rfc/rfc7240.html#section-4.4. This would allow the client to check whatPrefer
values are accepted:Using
Prefer: handling=lenient
would just accept and ignore thePrefer
, as we've always done.Details
The logic that filters the accepted Prefers is currently on the Response module.
postgrest/src/PostgREST/Response.hs
Line 73 in 8d3c9f8
postgrest/src/PostgREST/Response.hs
Line 101 in 8d3c9f8
It'd be better centralized at the Plan module. There we can fail and respond with an error.
The text was updated successfully, but these errors were encountered: