Added support for Flash clients.

master
Nicolas Favre-Felix 14 years ago
parent 03af4425dc
commit f931f18971

@ -36,6 +36,7 @@ curl -d "GET/hello" http://127.0.0.1:7379/
* Provide timeout (this needs to be added to hiredis first.)
* Multi-server support, using consistent hashing.
* Send your ideas using the github tracker, on twitter [@yowgi](http://twitter.com/yowgi) or by mail to n.favrefelix@gmail.com.
* Add WebSocket support, allow cross-origin XHR.
# HTTP error codes
* Unknown HTTP verb: 405 Method Not Allowed

@ -94,6 +94,26 @@ server_copy(const struct server *s) {
return ret;
}
/* Adobe flash cross-domain request */
void
on_flash_request(struct evhttp_request *rq, void *ctx) {
(void)ctx;
char out[] = "<?xml version=\"1.0\"?>\n"
"<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\n"
"<cross-domain-policy>\n"
"<allow-access-from domain=\"*\" />\n"
"</cross-domain-policy>\n";
struct evbuffer *body = evbuffer_new();
evbuffer_add(body, out, sizeof(out) - 1);
evhttp_add_header(rq->output_headers, "Content-Type", "application/xml");
evhttp_send_reply(rq, 200, "OK", body);
evbuffer_free(body);
}
void
on_request(struct evhttp_request *rq, void *ctx) {
@ -140,6 +160,7 @@ server_start(struct server *s) {
/* start http server */
evhttp_bind_socket(s->http, s->cfg->http_host, s->cfg->http_port);
evhttp_set_cb(s->http, "/crossdomain.xml", on_flash_request, s);
evhttp_set_gencb(s->http, on_request, s);
/* drop privileges */

Loading…
Cancel
Save