Skip to content

Commit

Permalink
core: add error 404 handling
Browse files Browse the repository at this point in the history
  • Loading branch information
0x501D committed Aug 17, 2020
1 parent 7b10217 commit 9a6debb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions libicap.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C" {
#define IC_CODE_OK 200
#define IC_CODE_NO_CONTENT 204
#define IC_CODE_BAD_REQUEST 400
#define IC_CODE_NOT_FOUND 404
#define IC_CODE_REQ_TIMEOUT 408

typedef struct ic_query {
Expand Down
3 changes: 3 additions & 0 deletions src/ic_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ IC_EXPORT const char *ic_err_msg[] = {
"Bad request",
"Cannot get methods list from server response",
"Connection to ICAP service is closed",
"ICAP service not found",
"Request timeout"
};

Expand Down Expand Up @@ -1580,6 +1581,8 @@ static int ic_read_from_service(ic_query_int_t *q)
rc = 2;
} else if (q->srv.rc == IC_CODE_REQ_TIMEOUT) {
return -IC_ERR_REQ_TIMEOUT;
} else if (q->srv.rc == IC_CODE_NOT_FOUND) {
return -IC_ERR_NOT_FOUND;
}

if (q->srv.null_body) {
Expand Down
1 change: 1 addition & 0 deletions src/ic_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum {
IC_ERR_METHODS_NOT_FOUND,
IC_ERR_CONN_CLOSED,
IC_ERR_REQ_TIMEOUT,
IC_ERR_NOT_FOUND,
IC_ERR_COUNT
};

Expand Down

0 comments on commit 9a6debb

Please sign in to comment.