Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 6357bba

Browse files
committed
fix(core): Rename HTTP status code
1 parent 08a5547 commit 6357bba

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

accelerator/errors.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ extern "C" {
5151
typedef enum {
5252
SC_OK = 0, /**< No error */
5353

54-
SC_HTTP_OK = 200, /**< HTTP response OK */
55-
SC_BAD_REQUEST = 400, /**< HTTP response, error when parsing request */
56-
SC_NOT_FOUND = 404, /**< HTTP request not found */
57-
SC_INTERNAL_SERVICE_ERROR = 500, /**< HTTP response, other errors in TA */
54+
SC_HTTP_OK = 200, /**< HTTP response OK */
55+
SC_HTTP_BAD_REQUEST = 400, /**< HTTP response, error when parsing request */
56+
SC_HTTP_NOT_FOUND = 404, /**< HTTP request not found */
57+
SC_HTTP_INTERNAL_SERVICE_ERROR = 500,
58+
/**< HTTP response, other errors in TA */
5859

5960
SC_TA_OOM = 0x01 | SC_MODULE_TA | SC_SEVERITY_FATAL,
6061
/**< Fail to create TA object */

accelerator/server.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ status_t set_response_content(status_t ret, char** json_result) {
2222

2323
cJSON* json_obj = cJSON_CreateObject();
2424
if ((ret & SC_ERROR_MASK) == 0x03) {
25-
http_ret = SC_NOT_FOUND;
25+
http_ret = SC_HTTP_NOT_FOUND;
2626
cJSON_AddStringToObject(json_obj, "message", "Request not found");
2727
} else if ((ret & SC_ERROR_MASK) == 0x07) {
28-
http_ret = SC_BAD_REQUEST;
28+
http_ret = SC_HTTP_BAD_REQUEST;
2929
cJSON_AddStringToObject(json_obj, "message", "Invalid request header");
3030
} else {
31-
http_ret = SC_INTERNAL_SERVICE_ERROR;
31+
http_ret = SC_HTTP_INTERNAL_SERVICE_ERROR;
3232
cJSON_AddStringToObject(json_obj, "message", "Internal service error");
3333
}
3434
*json_result = cJSON_PrintUnformatted(json_obj);
@@ -231,7 +231,7 @@ int main(int, char const**) {
231231
"Invalid request header");
232232
json_result = cJSON_PrintUnformatted(json_obj);
233233

234-
res.set_status(SC_BAD_REQUEST);
234+
res.set_status(SC_HTTP_BAD_REQUEST);
235235
cJSON_Delete(json_obj);
236236
} else {
237237
ret = api_send_transfer(&service, req.body().c_str(), &json_result);
@@ -260,7 +260,7 @@ int main(int, char const**) {
260260
cJSON_AddStringToObject(json_obj, "message", "Invalid path");
261261
const char* json = cJSON_PrintUnformatted(json_obj);
262262

263-
res.set_status(SC_BAD_REQUEST);
263+
res.set_status(SC_HTTP_BAD_REQUEST);
264264
res.set_header("Content-Type", "application/json");
265265
res.set_header("Access-Control-Allow-Origin", "*");
266266
res << json;

0 commit comments

Comments
 (0)