From 6a3ca7658e587d9bb063f330be3591bd4670fd35 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Tue, 19 Apr 2011 23:49:52 +0200 Subject: [PATCH] Add 'callback' query string parameter for JSONP. --- README.markdown | 2 +- client.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index b624ce7..e94eacc 100644 --- a/README.markdown +++ b/README.markdown @@ -21,7 +21,7 @@ curl -d "GET/hello" http://127.0.0.1:7379/ # Features * GET and POST are supported. -* JSON output by default, optional JSONP parameter (`?jsonp=myFunction`). +* JSON output by default, optional JSONP parameter (`?jsonp=myFunction` or `?callback=myFunction`). * Raw Redis 2.0 protocol output with `.raw` suffix * BSON support for compact responses and MongoDB compatibility. * HTTP 1.1 pipelining (70,000 http requests per second on a desktop Linux machine.) diff --git a/client.c b/client.c index f22c6a8..2dee020 100644 --- a/client.c +++ b/client.c @@ -105,7 +105,8 @@ http_client_on_query_string(struct http_parser *parser, const char *at, size_t s if(key_len == 4 && strncmp(key, "type", 4) == 0) { c->type = calloc(1 + val_len, 1); memcpy(c->type, val, val_len); - } else if(key_len == 5 && strncmp(key, "jsonp", 5) == 0) { + } else if((key_len == 5 && strncmp(key, "jsonp", 5) == 0) + || (key_len == 8 && strncmp(key, "callback", 8) == 0)) { c->jsonp = calloc(1 + val_len, 1); memcpy(c->jsonp, val, val_len); }