1
0
mirror of https://git.kore.io/kore.git synced 2024-11-16 15:06:37 +01:00

Stop hardcoding HTTP error codes in http_response() calls.

Use predefined HTTP_STATUS_* macros instead.
This commit is contained in:
Frederic Cambus 2021-04-21 14:36:39 +02:00 committed by Joris Vink
parent fb335e1e0c
commit 582e18d2ec
2 changed files with 6 additions and 6 deletions

View File

@ -90,12 +90,12 @@ kore_auth_run(struct http_request *req, struct kore_auth *auth)
kore_debug("kore_auth_run() for %s failed", req->path);
if (auth->redirect == NULL) {
http_response(req, 403, NULL, 0);
http_response(req, HTTP_STATUS_FORBIDDEN, NULL, 0);
return (KORE_RESULT_ERROR);
}
http_response_header(req, "location", auth->redirect);
http_response(req, 302, NULL, 0);
http_response(req, HTTP_STATUS_FOUND, NULL, 0);
return (KORE_RESULT_ERROR);
}

View File

@ -423,13 +423,13 @@ jsonrpc_error(struct jsonrpc_request *req, int code, const char *msg)
http_response_header(req->http, "content-type", "application/json");
yajl_gen_get_buf(req->gen, &body, &body_len);
succeeded:
http_response(req->http, 200, body, body_len);
http_response(req->http, HTTP_STATUS_OK, body, body_len);
if (req->gen != NULL)
yajl_gen_clear(req->gen);
jsonrpc_destroy_request(req);
return (KORE_RESULT_OK);
failed:
http_response(req->http, 500, NULL, 0);
http_response(req->http, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
jsonrpc_destroy_request(req);
return (KORE_RESULT_OK);
}
@ -466,13 +466,13 @@ jsonrpc_result(struct jsonrpc_request *req,
http_response_header(req->http, "content-type", "application/json");
yajl_gen_get_buf(req->gen, &body, &body_len);
succeeded:
http_response(req->http, 200, body, body_len);
http_response(req->http, HTTP_STATUS_OK, body, body_len);
if (req->gen != NULL)
yajl_gen_clear(req->gen);
jsonrpc_destroy_request(req);
return (KORE_RESULT_OK);
failed:
http_response(req->http, 500, NULL, 0);
http_response(req->http, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);
jsonrpc_destroy_request(req);
return (KORE_RESULT_OK);
}