master
Nicolas Favre-Felix 14 years ago
parent d140778c3f
commit b5b79c97df

@ -35,6 +35,7 @@ curl -d "GET/hello" http://127.0.0.1:7379/
* File upload with PUT.
# Ideas, TODO...
* Fix crash on ACL rejection.
* Add better support for PUT, DELETE, HEAD, OPTIONS? How? For which commands?
* MULTI/EXEC/DISCARD/WATCH are disabled at the moment; find a way to use them.
* Support POST of raw Redis protocol data, and execute the whole thing. This could be useful for MULTI/EXEC transactions.

@ -93,11 +93,11 @@ http_client_cleanup(struct http_client *c) {
free(c->output_headers.etag.s);
memset(&c->output_headers.etag, 0, sizeof(str_t));
free(c->qs_type.s);
memset(&c->qs_type, 0, sizeof(str_t));
free(c->query_string.type.s);
memset(&c->query_string.type, 0, sizeof(str_t));
free(c->qs_jsonp.s);
memset(&c->qs_jsonp, 0, sizeof(str_t));
free(c->query_string.jsonp.s);
memset(&c->query_string.jsonp, 0, sizeof(str_t));
memset(&c->verb, 0, sizeof(c->verb));
@ -235,9 +235,9 @@ http_on_query_string(http_parser *parser, const char *at, size_t length) {
}
if(key_len == 4 && strncmp(key, "type", 4) == 0) {
http_set_header(&c->qs_type, val, val_len);
http_set_header(&c->query_string.type, val, val_len);
} else if(key_len == 5 && strncmp(key, "jsonp", 5) == 0) {
http_set_header(&c->qs_jsonp, val, val_len);
http_set_header(&c->query_string.jsonp, val, val_len);
}
if(!and) {

@ -40,8 +40,10 @@ struct http_client {
} output_headers;
/* query string */
str_t qs_type;
str_t qs_jsonp;
struct {
str_t type;
str_t jsonp;
} query_string;
/* pub/sub */
struct subscription *sub;

@ -225,9 +225,9 @@ cmd_select_format(struct http_client *client, struct cmd *cmd,
}
/* the user can force it with ?type=some/thing */
if(client->qs_type.s) {
if(client->query_string.type.s) {
*f_format = custom_type_reply;
cmd->mime = strdup(client->qs_type.s);
cmd->mime = strdup(client->query_string.type.s);
cmd->mime_free = 1;
}

@ -112,14 +112,14 @@ json_string_output(json_t *j, struct cmd *cmd) {
char *json_reply = json_dumps(j, JSON_COMPACT);
/* check for JSONP */
if(cmd->client->qs_jsonp.s) {
if(cmd->client->query_string.jsonp.s) {
size_t json_len = strlen(json_reply);
size_t val_len = cmd->client->qs_jsonp.sz;
size_t val_len = cmd->client->query_string.jsonp.sz;
size_t ret_len = val_len + 1 + json_len + 3;
char *ret = calloc(1 + ret_len, 1);
memcpy(ret, cmd->client->qs_jsonp.s, val_len);
memcpy(ret, cmd->client->query_string.jsonp.s, val_len);
ret[val_len]='(';
memcpy(ret + val_len + 1, json_reply, json_len);
memcpy(ret + val_len + 1 + json_len, ");\n", 3);

Loading…
Cancel
Save