- Restconf error: added special case for translating from netconf invalid-value to 400 vs 404
- Added media to restconf sanity checks, such as bad client cert error
This commit is contained in:
parent
cdacca125c
commit
aed7dbfd8b
7 changed files with 118 additions and 130 deletions
|
|
@ -187,14 +187,15 @@ restconf_notimplemented(clicon_handle h,
|
|||
* @param[in] code If 0 use rfc8040 sec 7 netconf2restconf error-tag mapping
|
||||
* otherwise use this code
|
||||
* xerr should be on the form: <rpc-error>... otherwise an internal error is generated
|
||||
* @note there are special cases see code
|
||||
*/
|
||||
int
|
||||
api_return_err(clicon_handle h,
|
||||
void *req,
|
||||
cxobj *xerr,
|
||||
int pretty,
|
||||
api_return_err(clicon_handle h,
|
||||
void *req,
|
||||
cxobj *xerr,
|
||||
int pretty,
|
||||
restconf_media media,
|
||||
int code0)
|
||||
int code0)
|
||||
{
|
||||
int retval = -1;
|
||||
cbuf *cb = NULL;
|
||||
|
|
@ -203,6 +204,8 @@ api_return_err(clicon_handle h,
|
|||
char *tagstr;
|
||||
int code;
|
||||
cxobj *xerr2 = NULL;
|
||||
cxobj *xmsg;
|
||||
char *mb;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if ((cb = cbuf_new()) == NULL){
|
||||
|
|
@ -253,12 +256,18 @@ api_return_err(clicon_handle h,
|
|||
* 403 Forbidden If the user is not authorized to access a target resource or invoke
|
||||
* an operation
|
||||
*/
|
||||
cxobj *xmsg;
|
||||
char *mb;
|
||||
if ((xmsg = xpath_first(xerr, NULL, "error-message")) != NULL &&
|
||||
(mb = xml_body(xmsg)) != NULL &&
|
||||
strcmp(mb, "The requested URL was unauthorized") == 0)
|
||||
code = 401;
|
||||
code = 401; /* Unauthorized */
|
||||
}
|
||||
/* Special case #2 */
|
||||
if (code == 400){
|
||||
if (strcmp(tagstr, "invalid-value") == 0 &&
|
||||
(xmsg = xpath_first(xerr, NULL, "error-message")) != NULL &&
|
||||
(mb = xml_body(xmsg)) != NULL &&
|
||||
strcmp(mb, "Invalid HTTP data method") == 0)
|
||||
code = 404; /* Not found */
|
||||
}
|
||||
}
|
||||
if (restconf_reply_header(req, "Content-Type", "%s", restconf_media_int2str(media)) < 0) // XXX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue