Fix empty response for empty accounts
authorChip Black <bytex64@bytex64.net>
Fri, 24 Dec 2010 05:50:24 +0000 (23:50 -0600)
committerChip Black <bytex64@bytex64.net>
Fri, 24 Dec 2010 05:50:24 +0000 (23:50 -0600)
http_blerg.c

index a73ac1e..9078f53 100644 (file)
@@ -203,17 +203,13 @@ struct MHD_Response *create_response_for_range(struct blerg *b, uint64_t from, u
                return NULL;
        }
 
-       if (record_count == 0) {
-               response = MHD_create_response_from_data(2, "[]", MHD_NO, MHD_NO);
-       } else {
-               gs->entries = make_sequential_list(from, to);
-               gs->i = to - from;
+       gs->entries = make_sequential_list(from, to);
+       gs->i = to - from;
 
-               gs->g = yajl_gen_alloc(&yajl_c, NULL);
-               gs->yoff = gs->done = 0;
+       gs->g = yajl_gen_alloc(&yajl_c, NULL);
+       gs->yoff = gs->done = 0;
 
-               response = MHD_create_response_from_callback(-1, 262144, &GET_generate_list, gs, &GET_generate_list_free);
-       }
+       response = MHD_create_response_from_callback(-1, 262144, &GET_generate_list, gs, &GET_generate_list_free);
 
        return response;
 }
@@ -262,7 +258,7 @@ ahc_derp (void *cls, struct MHD_Connection *connection, const char *url, const c
                        uint64_t record_count, from, to;
                        record_count = blerg_get_record_count(b);
                        if (record_count == 0) {
-                               response = create_response_for_range(b, 0, 0);
+                               response = MHD_create_response_from_data(2, "[]", MHD_NO, MHD_NO);
                        } else {
                                to = record_count - 1;
                                from = (record_count > 50 ? to - 49 : 0);