diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3ab3597..06386c24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: - master - test-actions + - restconf-native-stream pull_request: branches: [ master ] diff --git a/apps/restconf/restconf_api_fcgi.c b/apps/restconf/restconf_api_fcgi.c index 30bdc2d4..9b5e102c 100644 --- a/apps/restconf/restconf_api_fcgi.c +++ b/apps/restconf/restconf_api_fcgi.c @@ -78,7 +78,7 @@ * XXX may be unecessary (or body start or something) */ FCGX_Request * -restconf_reply_body_start(void *req0) +restconf_reply_body_start(void *req0) { FCGX_Request *req = (FCGX_Request *)req0; @@ -102,10 +102,10 @@ restconf_reply_header(void *req0, ...) { FCGX_Request *req = (FCGX_Request *)req0; - int retval = -1; - size_t vlen; - char *value = NULL; - va_list ap; + int retval = -1; + size_t vlen; + char *value = NULL; + va_list ap; if (req == NULL || name == NULL || vfmt == NULL){ clixon_err(OE_CFG, EINVAL, "req, name or value is NULL"); @@ -151,11 +151,11 @@ restconf_reply_body_add(void *req0, ...) { FCGX_Request *req = (FCGX_Request *)req0; - int retval = -1; - size_t sz; - size_t blen; - char *body = NULL; - va_list ap; + int retval = -1; + size_t sz; + size_t blen; + char *body = NULL; + va_list ap; if (req == NULL || bfmt == NULL){ clixon_err(OE_CFG, EINVAL, "req or body is NULL"); @@ -208,7 +208,7 @@ restconf_reply_send(void *req0, { FCGX_Request *req = (FCGX_Request *)req0; int retval = -1; - const char *reason_phrase; + const char *reason_phrase; FCGX_SetExitStatus(code, req->out); if ((reason_phrase = restconf_code2reason(code)) == NULL) @@ -241,8 +241,8 @@ cbuf * restconf_get_indata(void *req0) { FCGX_Request *req = (FCGX_Request *)req0; - int c; - cbuf *cb = NULL; + int c; + cbuf *cb = NULL; if ((cb = cbuf_new()) == NULL) return NULL; diff --git a/apps/restconf/restconf_http1.c b/apps/restconf/restconf_http1.c index 1d11902b..3d6f5fa3 100644 --- a/apps/restconf/restconf_http1.c +++ b/apps/restconf/restconf_http1.c @@ -67,6 +67,9 @@ #include "clixon_http1_parse.h" #include "restconf_http1.h" #include "clixon_http_data.h" +#ifdef RESTCONF_NATIVE_STREAM +#include "restconf_stream.h" +#endif /* Size of xml read buffer */ #define BUFLEN 1024 @@ -310,7 +313,7 @@ restconf_http1_reply(restconf_conn *rc, * (Successful) response to a CONNECT request (Section 4.3.6 of * [RFC7231]). */ - if (sd->sd_code != 204 && sd->sd_code > 199) + if (sd->sd_code != 204 && sd->sd_code > 199 && !rc->rc_event_stream) if (restconf_reply_header(sd, "Content-Length", "%zu", sd->sd_body_len) < 0) goto done; /* Create reply and write headers */ @@ -450,6 +453,13 @@ restconf_http1_path_root(clixon_handle h, if (api_http_data(h, sd, sd->sd_qvec) < 0) goto done; } +#ifdef RESTCONF_NATIVE_STREAM + else if (api_path_is_stream(h)){ + restconf_socket *rs = rc->rc_socket; + if (api_stream(h, sd, sd->sd_qvec, rs->rs_stream_timeout, NULL) < 0) + goto done; + } +#endif else sd->sd_code = 404; /* catch all without body/media */ fail: diff --git a/apps/restconf/restconf_main_fcgi.c b/apps/restconf/restconf_main_fcgi.c index 878e54e7..24017004 100644 --- a/apps/restconf/restconf_main_fcgi.c +++ b/apps/restconf/restconf_main_fcgi.c @@ -88,12 +88,12 @@ #include "restconf_stream.h" /* Command line options to be passed to getopt(3) */ -#define RESTCONF_OPTS "hVD:f:E:l:C:p:d:y:a:u:rW:R:o:" +#define RESTCONF_OPTS "hVD:f:E:l:C:p:d:y:a:u:rW:R:t:o:" /*! Convert FCGI parameters to clixon runtime data * - * @param[in] h Clixon handle - * @param[in] envp Fastcgi request handle parameter array on the format "=" + * @param[in] h Clixon handle + * @param[in] envp Fastcgi request handle parameter array on the format "=" * @retval 0 OK * @retval -1 Error * @see https://nginx.org/en/docs/http/ngx_http_core_module.html#var_https @@ -285,6 +285,7 @@ usage(clixon_handle h, "\t-r \t\t Do not drop privileges if run as root\n" "\t-W \t Run restconf daemon as this user, drop according to CLICON_RESTCONF_PRIVILEGES\n" "\t-R \t Restconf configuration in-line overriding config file\n" + "\t-t \t Notification stream timeout in: quit after . For debug\n" "\t-o \"