diff --git a/ChangeLog b/ChangeLog index a4b7e0cd..84458e6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,34 @@ -2019-12-05 silvioprog +2020-03-19 silvioprog + + Bump v2.5.5 + +2020-03-12 silvioprog + + Removed experimental feature "sg_httpsrv_process()". (issue #9) + + Added experimental feature "sg_httpsrv_process()". + + Moved the error handling logic to the server. + + Bump v2.5.4 + +2020-03-11 silvioprog + + Forced the clients to leave from the server when it is shutting down. + + Removed the PDF generation for the library API reference. + + Upgraded PCRE library. + + Added markdown rules. + + Upgraded MHD and uthash libraries. + +2020-03-09 silvioprog + + Limited the shutdown time out based on the maximum connection time out of the clients. + +2019-12-10 silvioprog Bump v2.5.2 diff --git a/src/sg_httpres.c b/src/sg_httpres.c index 5969c28c..8d13de91 100644 --- a/src/sg_httpres.c +++ b/src/sg_httpres.c @@ -487,7 +487,11 @@ int sg_httpres_zsendstream2(struct sg_httpres *res, int level, uint64_t size, goto error_res; } res->status = status; +#ifdef SG_TESTING + errnum = 0; +#else return 0; +#endif error_res: sg_free(holder->buf_in); error_buf_in: @@ -563,7 +567,11 @@ int sg_httpres_zsendfile2(struct sg_httpres *res, int level, uint64_t size, goto error_res; } res->status = status; +#ifdef SG_TESTING + errnum = 0; +#else return 0; +#endif error_res: sg_free(holder->handle); error_handle: diff --git a/src/sg_httpsrv.h b/src/sg_httpsrv.h index f5292af1..17b19b89 100644 --- a/src/sg_httpsrv.h +++ b/src/sg_httpsrv.h @@ -7,7 +7,7 @@ * * Cross-platform library which helps to develop web servers or frameworks. * - * Copyright (C) 2016-2019 Silvio Clecio + * Copyright (C) 2016-2020 Silvio Clecio * * Sagui library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/sg_routes.c b/src/sg_routes.c index 211bb7af..508e53fe 100644 --- a/src/sg_routes.c +++ b/src/sg_routes.c @@ -59,7 +59,7 @@ static struct sg_route *sg__route_new(const char *pattern, char *errmsg, route->pattern = sg_malloc(off); if (!route->pattern) { *errnum = ENOMEM; - goto fail; + goto error; } snprintf(route->pattern, off, ((*pattern == '(') ? "%s" : "^%s$"), pattern); route->re = pcre2_compile((PCRE2_SPTR) route->pattern, PCRE2_ZERO_TERMINATED, @@ -70,7 +70,7 @@ static struct sg_route *sg__route_new(const char *pattern, char *errmsg, _("Pattern compilation failed at offset %d: %s.\n"), (unsigned int) off, err); *errnum = EINVAL; - goto fail; + goto error; } #ifdef PCRE2_JIT_SUPPORT *errnum = pcre2_jit_compile(route->re, PCRE2_JIT_COMPLETE); @@ -78,7 +78,7 @@ static struct sg_route *sg__route_new(const char *pattern, char *errmsg, pcre2_get_error_message(*errnum, err, sizeof(err)); snprintf(errmsg, errlen, _("JIT compilation failed: %s.\n"), err); *errnum = EINVAL; - goto fail; + goto error; } #endif route->match = pcre2_match_data_create_from_pattern(route->re, NULL); @@ -86,12 +86,12 @@ static struct sg_route *sg__route_new(const char *pattern, char *errmsg, strncpy(errmsg, _("Cannot allocate match data from the pattern.\n"), errlen); *errnum = EINVAL; - goto fail; + goto error; } route->cb = cb; route->cls = cls; return route; -fail: +error: sg__route_free(route); return NULL; } diff --git a/src/sg_strmap.c b/src/sg_strmap.c index a9cbc34e..8dc4a7f9 100644 --- a/src/sg_strmap.c +++ b/src/sg_strmap.c @@ -36,16 +36,16 @@ struct sg_strmap *sg__strmap_new(const char *name, const char *val) { return NULL; pair->key = strdup(name); if (!pair->key) - goto fail; + goto error; pair->name = strdup(name); if (!pair->name) - goto fail; + goto error; pair->val = strdup(val); if (!pair->val) - goto fail; + goto error; sg__toasciilower(pair->key); return pair; -fail: +error: sg__strmap_free(pair); return NULL; } diff --git a/test/test_httpres.c b/test/test_httpres.c index ae6a0672..7700f455 100644 --- a/test/test_httpres.c +++ b/test/test_httpres.c @@ -157,11 +157,6 @@ static void test_httpres_sendbinary(struct sg_httpres *res) { MHD_destroy_response(res->handle); res->handle = NULL; res->status = 0; - ASSERT(sg_httpres_sendbinary(res, "", len, "text/plain", 200) == 0); - ASSERT(res->status == 200); - MHD_destroy_response(res->handle); - res->handle = NULL; - res->status = 0; ASSERT(sg_httpres_sendbinary(res, "foo", 0, "text/plain", 200) == 0); ASSERT(res->status == 200); MHD_destroy_response(res->handle); diff --git a/test/test_httpsrv.c b/test/test_httpsrv.c index 7fc835c4..6c2d9144 100644 --- a/test/test_httpsrv.c +++ b/test/test_httpsrv.c @@ -7,7 +7,7 @@ * * Cross-platform library which helps to develop web servers or frameworks. * - * Copyright (C) 2016-2019 Silvio Clecio + * Copyright (C) 2016-2020 Silvio Clecio * * Sagui library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/test/test_utils.c b/test/test_utils.c index 2106025e..3134818e 100644 --- a/test/test_utils.c +++ b/test/test_utils.c @@ -449,11 +449,8 @@ static void test_ip(void) { ASSERT(sg_ip(&sa, buf, -1) == EINVAL); sa.sa_family = AF_INET; - ASSERT(sg_ip(&sa, buf, 16) == 0); + ASSERT(sg_ip(&sa, buf, sizeof(buf)) == 0); ASSERT(strcmp(buf, "0.0.0.0") == 0); - sa.sa_family = AF_INET6; - ASSERT(sg_ip(&sa, buf, 46) == 0); - ASSERT(strlen(buf) > 0); /* we do not need massive testing for inet_ntop() since it is already tested by the glibc team. */ }