Added generic CORS header adder, now used in controller, HLS output and internal HTTP handler.

This commit is contained in:
Thulinma 2015-05-12 11:23:00 +02:00
parent 2845cbedcb
commit a3bf393bea
5 changed files with 20 additions and 5 deletions

View file

@ -32,6 +32,15 @@ void HTTP::Parser::CleanPreserveHeaders() {
vars.clear();
}
/// Sets the neccesary headers to allow Cross Origin Resource Sharing with all domains.
void HTTP::Parser::setCORSHeaders(){
SetHeader("Access-Control-Allow-Origin", "*");
SetHeader("Access-Control-Allow-Methods", "GET, POST");
SetHeader("Access-Control-Allow-Headers", "Content-Type, X-Requested-With");
SetHeader("Access-Control-Allow-Credentials", "true");
}
/// Returns a string containing a valid HTTP 1.0 or 1.1 request, ready for sending.
/// The request is build from internal variables set before this call is made.
/// To be precise, method, url, protocol, headers and body are used.

View file

@ -21,6 +21,7 @@ namespace HTTP {
std::string getUrl();
void SetHeader(std::string i, std::string v);
void SetHeader(std::string i, long long v);
void setCORSHeaders();
void SetVar(std::string i, std::string v);
void SetBody(std::string s);
void SetBody(char * buffer, int len);