Add basic CORS headers to allow cross-site access.
Add ¨Access-Control-Allow-Origin: *¨ to the HTTP headers of all replies. This allows use in a cross-origin AJAX situation. In compliance with the recommendations of section 4.2 of RFC2616, the header is added before the existing entity headers.
This commit is contained in:
parent
f7657280b6
commit
c6840496c0
@ -139,11 +139,13 @@ Reply Reply::stockReply(Reply::status_type status) {
|
||||
Reply rep;
|
||||
rep.status = status;
|
||||
rep.content = ToString(status);
|
||||
rep.headers.resize(2);
|
||||
rep.headers[0].name = "Content-Length";
|
||||
rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size());
|
||||
rep.headers[1].name = "Content-Type";
|
||||
rep.headers[1].value = "text/html";
|
||||
rep.headers.resize(3);
|
||||
rep.headers[0].name = "Access-Control-Allow-Origin";
|
||||
rep.headers[0].value = "*";
|
||||
rep.headers[1].name = "Content-Length";
|
||||
rep.headers[1].value = boost::lexical_cast<std::string>(rep.content.size());
|
||||
rep.headers[2].name = "Content-Type";
|
||||
rep.headers[2].value = "text/html";
|
||||
return rep;
|
||||
}
|
||||
} // namespace http
|
||||
|
Loading…
Reference in New Issue
Block a user