+struct MHD_Response *create_response_for_range(struct blerg *b, uint64_t from, uint64_t to) {
+ struct MHD_Response *response;
+ struct get_state *gs = malloc(sizeof(struct get_state));
+ gs->b = b;
+
+ uint64_t record_count = blerg_get_record_count(b);
+
+ if (from > to || from >= record_count || to >= record_count || to - from > 99) {
+ blerg_close(b);
+ free(gs);
+ 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->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);
+ }
+
+ return response;
+}
+