WebDAV-Daemon icon indicating copy to clipboard operation
WebDAV-Daemon copied to clipboard

Add support for custom headers

Open sbluhm opened this issue 5 years ago • 3 comments

Users might need custom headers. Especially, if you want to allow CORS. For example: Access-Control-Allow-Origin: 'https://www.example.com' Access-Control-Allow-Headers: 'cache-control'

This could be included in the server section of the config.xml

sbluhm avatar Sep 19 '20 17:09 sbluhm

This seems like a reasonable request. Is it acceptable for your purposes to add these headers to every response (error or success, GET, PUT or OPTIONS?)

couling avatar Sep 20 '20 20:09 couling

This is how I approached it. Making sure/disclaiming the headers are ALWAYS injected on a per-server basis.

I have done it for both legs of the first "if" statement of sendResponse: https://github.com/sbluhm/WebDAV-Daemon/blob/CustomHeaders/webdavd.c#L1589 https://github.com/sbluhm/WebDAV-Daemon/blob/CustomHeaders/webdavd.c#L1628 Would there be a better place?

sbluhm avatar Sep 21 '20 05:09 sbluhm

Actually, I have the pull request ready now. Can you please have a look at line https://github.com/sbluhm/WebDAV-Daemon/blame/CustomHeaders/configuration.c#L283 for me? I am not releasing the memory for xmlTextReaderGetAttribute here and have no clue how to do this. According to the documentation, you have to de-allocate it.

sbluhm avatar Sep 21 '20 14:09 sbluhm