Added text reply for statuses and errors. (Fix GitHub issue #29)

master
Nicolas Favre-Felix 13 years ago
parent 8136f9270f
commit fe88099ee5

@ -14,6 +14,7 @@ custom_type_reply(redisAsyncContext *c, void *r, void *privdata) {
struct cmd *cmd = privdata;
(void)c;
char int_buffer[50];
char *status_buf;
int int_len;
struct http_response *resp;
@ -33,6 +34,15 @@ custom_type_reply(redisAsyncContext *c, void *r, void *privdata) {
format_send_reply(cmd, reply->str, reply->len, cmd->mime);
return;
case REDIS_REPLY_STATUS:
case REDIS_REPLY_ERROR:
status_buf = calloc(1 + reply->len, 1);
status_buf[0] = (reply->type == REDIS_REPLY_STATUS ? '+' : '-');
memcpy(status_buf + 1, reply->str, reply->len);
format_send_reply(cmd, status_buf, 1 + reply->len, cmd->mime);
free(status_buf);
return;
case REDIS_REPLY_INTEGER:
int_len = sprintf(int_buffer, "%lld", reply->integer);
format_send_reply(cmd, int_buffer, int_len, cmd->mime);

Loading…
Cancel
Save