diff options
author | Michael McVady <femtonaut@gmail.com> | 2023-01-02 11:19:46 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2023-01-02 11:19:46 -0600 |
commit | ad5f6b20264ca4abc19bc470bff070b75eaf61f9 (patch) | |
tree | 806f9704c49822a0483284b5d2918f72540f6b19 /src | |
parent | 9c25735888a47dbba8ee536836b5c0a3dd75f627 (diff) |
Fix JSON HTTP 404
Diffstat (limited to 'src')
-rw-r--r-- | src/clog.c | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -320,6 +320,7 @@ render_posts_json(struct post_request *post_req) ") row;" ); } + if (err == KORE_RESULT_ERROR) { post_req->resp_status = HTTP_STATUS_INTERNAL_ERROR; @@ -327,24 +328,14 @@ render_posts_json(struct post_request *post_req) goto out; } - rows = kore_pgsql_ntuples(&sql); - kore_log(LOG_DEBUG, "JSON rows: %d", rows); - - int fields = kore_pgsql_nfields(&sql); - kore_log(LOG_DEBUG, "JSON fields: %d", fields); - - int len = kore_pgsql_getlength(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON fields: %d", fields); - - kore_pgsql_logerror(&sql); + if (kore_pgsql_getlength(&sql, 0, 0) == 0) + { + post_req->resp_status = HTTP_STATUS_NOT_FOUND; + goto out; + } if (rows == 1) { json = kore_pgsql_getvalue(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON data: %s", json); - - len = kore_pgsql_getlength(&sql, 0, 0); - kore_log(LOG_DEBUG, "JSON data len: %d", len); - kore_buf_append( post_req->resp_buf, json, |