karlheyes / icecast-kh

KH branch of icecast
GNU General Public License v2.0
297 stars 105 forks source link

fix: always send cors and user headers on response #435

Closed eshaz closed 8 months ago

eshaz commented 9 months ago

This PR is to fix an issue where CORS headers, and possibly other user configured headers, are not being sent on the HTTP response for redirects triggered from the below section. It looks like there was some recent additions to work around iOS quirks that are using this flow, so the issue is apparent only in iOS.

https://github.com/karlheyes/icecast-kh/blob/a8cfaae2bde027f714b8d1099c5adb88f4bed922/src/format.c#L381-L392

The line removed in these changes appears to be improperly filtering out the CORS headers from the response, causing the cross-origin redirect to fail in iOS. See eshaz/icecast-metadata-js#186

karlheyes commented 8 months ago

Assuming the issue is just relating to a redirect then the headers can be expanded to include those status codes eg

params.c lines 517+ { .hdr = { .status = "2", .name = "Access-Control-Allow-Origin", .value = "", .callback = _send_cors_hdr } }, { .hdr = { .status = "2", .name = "Access-Control-Allow-Credentials", .value = "True", .callback = _send_cors_hdr } }, { .hdr = { .status = "2", .name = "Access-Control-Allow-Headers", .value = "Origin, Icy-MetaData, Range", .callback = _send_cors_hdr } }, { .hdr = { .status = "2", .name = "Access-Control-Expose-Headers", .value = "Icy-Br, Icy-Description, Icy-Genre, Icy-MetaInt, Icy-Name, Icy-Pub, Icy-Url", .callback = _send_cors_hdr } }, { .hdr = { .status = "2", .name = "Access-Control-Allow-Methods", .value = "GET, OPTIONS, SOURCE, PUT, HEAD, STATS", .callback = _send_cors_hdr } },

change those "2" to "[23]

karl

eshaz commented 8 months ago

That suggestion worked great, and I've updated the PR. Thanks!

karlheyes commented 8 months ago

This is now in master

karl