diff options
Diffstat (limited to 'src/supplemental/http/http_server.c')
| -rw-r--r-- | src/supplemental/http/http_server.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c index ba89626b..fa9ad2f4 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -1416,7 +1416,6 @@ http_handle_file(nni_aio *aio) return; } if (((rv = nni_http_res_alloc(&res)) != 0) || - ((rv = nni_http_res_set_status(res, NNG_HTTP_STATUS_OK)) != 0) || ((rv = nni_http_res_set_header(res, "Content-Type", ctype)) != 0) || ((rv = nni_http_res_copy_data(res, data, size)) != 0)) { @@ -1426,6 +1425,8 @@ http_handle_file(nni_aio *aio) return; } + nni_http_res_set_status(res, NNG_HTTP_STATUS_OK); + nni_free(data, size); nni_aio_set_output(aio, 0, res); nni_aio_finish(aio, 0, 0); @@ -1610,7 +1611,6 @@ http_handle_dir(nni_aio *aio) } if (((rv = nni_http_res_alloc(&res)) != 0) || - ((rv = nni_http_res_set_status(res, NNG_HTTP_STATUS_OK)) != 0) || ((rv = nni_http_res_set_header(res, "Content-Type", ctype)) != 0) || ((rv = nni_http_res_copy_data(res, data, size)) != 0)) { @@ -1620,6 +1620,8 @@ http_handle_dir(nni_aio *aio) return; } + nni_http_res_set_status(res, NNG_HTTP_STATUS_OK); + nni_free(data, size); nni_aio_set_output(aio, 0, res); nni_aio_finish(aio, 0, 0); @@ -1707,7 +1709,6 @@ http_handle_redirect(nni_aio *aio) // discard it. if ((rv != 0) || ((rv = nni_http_res_alloc(&r)) != 0) || ((rv = nni_http_alloc_html_error(&html, hr->code, msg)) != 0) || - ((rv = nni_http_res_set_status(r, hr->code)) != 0) || ((rv = nni_http_res_set_header(r, "Connection", "close")) != 0) || ((rv = nni_http_res_set_header( r, "Content-Type", "text/html; charset=UTF-8")) != 0) || @@ -1722,6 +1723,9 @@ http_handle_redirect(nni_aio *aio) nni_aio_finish_error(aio, rv); return; } + + nni_http_res_set_status(r, hr->code); + if (loc != hr->where) { nni_strfree(loc); } @@ -1807,13 +1811,14 @@ http_handle_static(nni_aio *aio) if (((rv = nni_http_res_alloc(&r)) != 0) || ((rv = nni_http_res_set_header(r, "Content-Type", ctype)) != 0) || - ((rv = nni_http_res_set_status(r, NNG_HTTP_STATUS_OK)) != 0) || ((rv = nni_http_res_set_data(r, hs->data, hs->size)) != 0)) { nni_http_res_free(r); nni_aio_finish_error(aio, rv); return; } + nni_http_res_set_status(r, NNG_HTTP_STATUS_OK); + nni_aio_set_output(aio, 0, r); nni_aio_finish(aio, 0, 0); } |
