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

wsgidav.response_headers only added to GET/HEAD requests #154

Closed
SteffenDE opened this issue May 8, 2019 · 6 comments
Closed

wsgidav.response_headers only added to GET/HEAD requests #154

SteffenDE opened this issue May 8, 2019 · 6 comments

Comments

@SteffenDE
Copy link
Contributor

The custom headers should be included in every response, not only when using GET/HEAD.

if "response_headers" in environ["wsgidav.config"]:
customHeaders = environ["wsgidav.config"]["response_headers"]
for header, value in customHeaders:
response_headers.append((header, value))
res.finalize_headers(environ, response_headers)

Also, res.finalize_headers() should be called.

@mar10
Copy link
Owner

mar10 commented May 9, 2019

Can you give a use case? #90 seems to be ok with setting headers on every request. I am not sure if this is always the case and we might need to extend the configuration?

@SteffenDE
Copy link
Contributor Author

#90 talked about the "Access-Control-Allow-Origin" header. Adding this header to the response_headers configuration currently does not help at all, as for CORS to work (https://developer.mozilla.org/de/docs/Web/HTTP/CORS), the headers must be added to every request. Currently, they are only added to GET and HEAD requests. CORS is actually a little bit more complex, so maybe there should be a middleware for that, but still I think response_headers should be applied to every request.

Trying to do a CORS request from the browser:
Bildschirmfoto 2019-05-09 um 21 50 57
response_headers added to GET:
Bildschirmfoto 2019-05-09 um 21 51 12
response_headers not added to OPTIONS:
Bildschirmfoto 2019-05-09 um 21 51 20
response_headers not added to PUT:
Bildschirmfoto 2019-05-09 um 21 51 32

For my use-case I actually tried to achieve setting a cookie from a Directory Controller (verifying basic auth credentials on every request is very expensive using modern password hash algorithms) and some clients support sending cookies instead. I "fixed" this by caching a hash of the username+password combination in memory using a faster hash algorithm (blake2) and storing that hash (and the auth result) for 60 seconds. Therefore, clients that send many requests at once (like macOS Finder when unpacking a ZIP file on a WebDAV drive) does not require hashing the password all the time.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 16, 2020
@mar10 mar10 removed the stale label Mar 17, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Jun 16, 2020
@mar10 mar10 removed the stale label Jun 16, 2020
@mar10
Copy link
Owner

mar10 commented Jun 27, 2020

Started a branch: append_custom_headers

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants