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

Add ability to set error response headers #801

Open
epompeii opened this issue Oct 16, 2023 · 1 comment
Open

Add ability to set error response headers #801

epompeii opened this issue Oct 16, 2023 · 1 comment

Comments

@epompeii
Copy link
Contributor

epompeii commented Oct 16, 2023

I currently have response headers working for CORS, after looking at how Oxide does so in cio: https://github.com/bencherdev/bencher/blob/main/services/api/src/util/headers.rs
I think this may solve: #57

But there is no way to set error response headers.

The headers for a valid request look like this (happy CORS):

access-control-allow-headers | Content-Type
access-control-allow-methods | GET
access-control-allow-origin | *
content-length | 255
content-type | application/json
date | Sun, 15 Oct 2023 23:43:19 GMT
x-request-id | 46e28335-f418-4731-ae94-a73588908f63

But the headers for an error request look like this (unhappy CORS):

content-length | 133
content-type | application/json
date | Sun, 15 Oct 2023 23:43:33 GMT
x-request-id | 0c32030a-a999-4b42-9a0f-653696564e26

Internally, it looks like dropshot uses this HttpError into_response method: https://docs.rs/dropshot/latest/src/dropshot/error.rs.html#237
So it would be great to be able to add additional headers to HttpError or just have it also use the headers set for a valid request.

@davepacheco
Copy link
Collaborator

Yeah. See also #57. We left out error responses when we did #283. Also related are #39, #41.

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

2 participants