From: Josh Dvir Date: Thu, 9 Jul 2015 07:03:11 +0000 (+0300) Subject: Adding CORS headers X-Git-Tag: v4.2.1~2105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=febb1c1f750e44cdd2773af04ea8552b409713ca;p=thirdparty%2Ftvheadend.git Adding CORS headers Hi, This implements https://tvheadend.org/issues/852 I'm currently building a web UI and I want it to be static HTML no server side code. Thanks --- diff --git a/src/http.c b/src/http.c index 7d16be01a..54df47b2b 100644 --- a/src/http.c +++ b/src/http.c @@ -235,9 +235,13 @@ http_send_header(http_connection_t *hc, int rc, const char *content, htsbuf_qprintf(&hdrs, "%s %d %s\r\n", http_ver2str(hc->hc_version), rc, http_rc2str(rc)); - if (hc->hc_version != RTSP_VERSION_1_0) + if (hc->hc_version != RTSP_VERSION_1_0){ htsbuf_qprintf(&hdrs, "Server: HTS/tvheadend\r\n"); - + htsbuf_qprintf(&hdrs, "Access-Control-Allow-Origin: *\r\n"); + htsbuf_qprintf(&hdrs, "Access-Control-Allow-Methods: POST, GET\r\n"); + htsbuf_qprintf(&hdrs, "Access-Control-Allow-Headers: x-requested-with\r\n"); + } + if(maxage == 0) { if (hc->hc_version != RTSP_VERSION_1_0) htsbuf_qprintf(&hdrs, "Cache-Control: no-cache\r\n");