Restconf and http/1 modifications for http/1-only
This commit is contained in:
parent
c006c6189d
commit
61661e6940
10 changed files with 77 additions and 75 deletions
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
%type <string> body
|
||||
%type <string> absolute_paths
|
||||
%type <string> absolute_paths1
|
||||
%type <string> absolute_path
|
||||
%type <string> field_vchars
|
||||
%type <string> field_values
|
||||
|
|
@ -230,7 +231,8 @@ body : body BODY
|
|||
| { _PARSE_DEBUG("body -> "); $$ = NULL; }
|
||||
;
|
||||
|
||||
/* request-line = method SP request-target SP HTTP-version CRLF */request_line : method SP request_target SP HTTP_version CRLF
|
||||
/* request-line = method SP request-target SP HTTP-version CRLF */
|
||||
request_line : method SP request_target SP HTTP_version CRLF
|
||||
{
|
||||
_PARSE_DEBUG("request-line -> method request-target HTTP_version CRLF");
|
||||
}
|
||||
|
|
@ -255,14 +257,14 @@ method : TOKEN
|
|||
* query = <query, see [RFC3986], Section 3.4>
|
||||
* query = *( pchar / "/" / "?" )
|
||||
*/
|
||||
request_target : absolute_paths
|
||||
request_target : absolute_paths1
|
||||
{
|
||||
if (restconf_param_set(_HY->hy_h, "REQUEST_URI", $1) < 0)
|
||||
YYABORT;
|
||||
free($1);
|
||||
_PARSE_DEBUG("request-target -> absolute-paths");
|
||||
_PARSE_DEBUG("request-target -> absolute-paths1");
|
||||
}
|
||||
| absolute_paths QMARK QUERY
|
||||
| absolute_paths1 QMARK QUERY
|
||||
{
|
||||
if (restconf_param_set(_HY->hy_h, "REQUEST_URI", $1) < 0)
|
||||
YYABORT;
|
||||
|
|
@ -270,10 +272,19 @@ request_target : absolute_paths
|
|||
if (http1_parse_query(_HY, $3) < 0)
|
||||
YYABORT;
|
||||
free($3);
|
||||
_PARSE_DEBUG("request-target -> absolute-paths ? query");
|
||||
_PARSE_DEBUG("request-target -> absolute-paths1 ? query");
|
||||
}
|
||||
;
|
||||
|
||||
/* absolute-paths1 = absolute-paths ["/"]
|
||||
* Not according to standards: trailing /
|
||||
*/
|
||||
absolute_paths1 : absolute_paths
|
||||
{ $$ = $1;_PARSE_DEBUG("absolute-paths1 -> absolute-paths "); }
|
||||
| absolute_paths SLASH
|
||||
{ $$ = $1;_PARSE_DEBUG("absolute-paths1 -> absolute-paths / "); }
|
||||
;
|
||||
|
||||
/* absolute-path = 1*( "/" segment ) */
|
||||
absolute_paths : absolute_paths absolute_path
|
||||
{
|
||||
|
|
|
|||
|
|
@ -403,6 +403,8 @@ restconf_http1_path_root(clicon_handle h,
|
|||
/* Check sanity of session, eg ssl client cert validation, may set rc_exit */
|
||||
if (restconf_connection_sanity(h, rc, sd) < 0)
|
||||
goto done;
|
||||
if (rc->rc_exit)
|
||||
goto fail;
|
||||
#ifdef HAVE_LIBNGHTTP2
|
||||
if ((ret = http1_upgrade_http2(h, sd)) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -596,6 +596,7 @@ restconf_http1(restconf_conn *rc,
|
|||
clicon_handle h;
|
||||
int ret;
|
||||
int status;
|
||||
cbuf *cberr = NULL;
|
||||
|
||||
h = rc->rc_h;
|
||||
if ((sd = restconf_stream_find(rc, 0)) == NULL){
|
||||
|
|
@ -643,12 +644,17 @@ restconf_http1(restconf_conn *rc,
|
|||
(*readmore)++;
|
||||
goto ok;
|
||||
}
|
||||
/* Return error. Honsetly, the sender could just e slow, it should really be a
|
||||
/* Return error. Honestly, the sender could just e slow, it should really be a
|
||||
* timeout here.
|
||||
*/
|
||||
if (native_send_badrequest(h, rc->rc_s, rc->rc_ssl, "application/yang-data+xml",
|
||||
"<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\"><error><error-type>protocol</error-type><error-tag>malformed-message</error-tag><error-message>The requested URL or a header is in some way badly formed</error-message></error></errors>") < 0)
|
||||
if ((cberr = cbuf_new()) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
||||
goto done;
|
||||
}
|
||||
cprintf(cberr, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\"><error><error-type>protocol</error-type><error-tag>malformed-message</error-tag><error-message>%s</error-message></error></errors>", clicon_err_reason);
|
||||
if (native_send_badrequest(h, rc->rc_s, rc->rc_ssl, "application/yang-data+xml", cbuf_get(cberr)) < 0)
|
||||
goto done;
|
||||
goto ok;
|
||||
}
|
||||
/* Check for Continue and if so reply with 100 Continue
|
||||
* ret == 1: send reply
|
||||
|
|
@ -677,6 +683,10 @@ restconf_http1(restconf_conn *rc,
|
|||
(*readmore)++;
|
||||
goto ok;
|
||||
}
|
||||
/* nginx compatible, set HTTPS parameter if SSL */
|
||||
if (rc->rc_ssl)
|
||||
if (restconf_param_set(h, "HTTPS", "https") < 0)
|
||||
goto done;
|
||||
/* main restconf processing */
|
||||
if (restconf_http1_path_root(h, rc) < 0)
|
||||
goto done;
|
||||
|
|
@ -685,6 +695,7 @@ restconf_http1(restconf_conn *rc,
|
|||
goto done;
|
||||
cvec_reset(sd->sd_outp_hdrs); /* Can be done in native_send_reply */
|
||||
cbuf_reset(sd->sd_outp_buf);
|
||||
cbuf_reset(sd->sd_inbuf);
|
||||
if (rc->rc_exit){ /* Server-initiated exit */
|
||||
SSL_free(rc->rc_ssl);
|
||||
rc->rc_ssl = NULL;
|
||||
|
|
@ -700,11 +711,14 @@ restconf_http1(restconf_conn *rc,
|
|||
ok:
|
||||
retval = 1;
|
||||
done:
|
||||
if (cberr)
|
||||
cbuf_free(cberr);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBNGHTTP2
|
||||
#ifdef HAVE_HTTP1
|
||||
static int
|
||||
restconf_http2_upgrade(restconf_conn *rc)
|
||||
{
|
||||
|
|
@ -763,6 +777,7 @@ restconf_http2_upgrade(restconf_conn *rc)
|
|||
done:
|
||||
return retval;
|
||||
}
|
||||
#endif /* HAVE_LIBHTTP1 */
|
||||
|
||||
/*!
|
||||
* @param[in] buf Input buffer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue