From 0863d12e2b5173efeb074cbc9fa05f26274f126b Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 12 Sep 2018 12:48:13 -0700 Subject: fixes #717 need nng_http_req_reset and nng_http_res_reset fixes #718 http_transact is still not right fixes #719 calculation of buffer size is incorrect in http --- docs/man/CMakeLists.txt | 2 ++ docs/man/libnng.3.adoc | 2 ++ docs/man/nng_http_req_alloc.3http.adoc | 5 ++++ docs/man/nng_http_req_free.3http.adoc | 4 +++ docs/man/nng_http_req_reset.3http.adoc | 48 ++++++++++++++++++++++++++++++++++ docs/man/nng_http_res_alloc.3http.adoc | 5 ++-- docs/man/nng_http_res_free.3http.adoc | 6 ++++- docs/man/nng_http_res_reset.3http.adoc | 44 +++++++++++++++++++++++++++++++ 8 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 docs/man/nng_http_req_reset.3http.adoc create mode 100644 docs/man/nng_http_res_reset.3http.adoc (limited to 'docs/man') diff --git a/docs/man/CMakeLists.txt b/docs/man/CMakeLists.txt index e39f2da3..5381f1e5 100644 --- a/docs/man/CMakeLists.txt +++ b/docs/man/CMakeLists.txt @@ -238,6 +238,7 @@ if (NNG_ENABLE_DOC) nng_http_req_get_method nng_http_req_get_uri nng_http_req_get_version + nng_http_req_reset nng_http_req_set_data nng_http_req_set_header nng_http_req_set_method @@ -254,6 +255,7 @@ if (NNG_ENABLE_DOC) nng_http_res_get_reason nng_http_res_get_status nng_http_res_get_version + nng_http_res_reset nng_http_res_set_data nng_http_res_set_header nng_http_res_set_reason diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc index 299b73ef..0a62f931 100644 --- a/docs/man/libnng.3.adoc +++ b/docs/man/libnng.3.adoc @@ -311,6 +311,7 @@ and connections. |<>|return HTTP request method |<>|return HTTP request URI |<>|return HTTP request protocol version +|<>|reset HTTP request structure |<>|set HTTP request body |<>|set HTTP request header |<>|set HTTP request method @@ -327,6 +328,7 @@ and connections. |<>|return HTTP response reason |<>|return HTTP response status |<>|return HTTP response protocol version +|<>|reset HTTP response structure |<>|set HTTP response body |<>|set HTTP response header |<>|set HTTP response reason diff --git a/docs/man/nng_http_req_alloc.3http.adoc b/docs/man/nng_http_req_alloc.3http.adoc index 3a522b3e..fe7458de 100644 --- a/docs/man/nng_http_req_alloc.3http.adoc +++ b/docs/man/nng_http_req_alloc.3http.adoc @@ -30,6 +30,10 @@ and stores a pointer to it in __reqp__. The request will be initialized to perform an HTTP/1.1 `GET` operation using the URL specified in __url__. +TIP: It is possible to specify `NULL` for the URL. +In this case the URI for the request must be specified by a subsequent call +to `<>`. + == RETURN VALUES This function returns 0 on success, and non-zero otherwise. @@ -53,6 +57,7 @@ This function returns 0 on success, and non-zero otherwise. <>, <>, <>, +<>, <>, <>, <>, diff --git a/docs/man/nng_http_req_free.3http.adoc b/docs/man/nng_http_req_free.3http.adoc index df86c5da..2564c422 100644 --- a/docs/man/nng_http_req_free.3http.adoc +++ b/docs/man/nng_http_req_free.3http.adoc @@ -28,6 +28,9 @@ void nng_http_req_free(nng_http_req *req); The `nng_http_req_free()` function deallocates the HTTP request structure _req_ entirely. +TIP: Instead of freeing and reallocating request structures, it is possible +to reuse _req_ with `<>`. + == RETURN VALUES None. @@ -40,4 +43,5 @@ None. [.text-left] <>, +<>, <> diff --git a/docs/man/nng_http_req_reset.3http.adoc b/docs/man/nng_http_req_reset.3http.adoc new file mode 100644 index 00000000..9aab704a --- /dev/null +++ b/docs/man/nng_http_req_reset.3http.adoc @@ -0,0 +1,48 @@ += nng_http_req_reset(3http) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_http_req_reset - reset HTTP request structure + +== SYNOPSIS + +[source, c] +---- +#include +#include + +void nng_http_req_reset(nng_http_req *req); +---- + +== DESCRIPTION + +The `nng_http_req_reset()` function resets the request __req__ so that it +is just as if it had been freshly allocated with +`<>` with a `NULL` URL. + +NOTE: Before using this with an HTTP operation, the URI must be set using +`<>`. + +== RETURN VALUES + +None. + +== ERRORS + +None. + +== SEE ALSO + +[.text-left] +<>, +<>, +<> diff --git a/docs/man/nng_http_res_alloc.3http.adoc b/docs/man/nng_http_res_alloc.3http.adoc index 2b7699a7..b395b502 100644 --- a/docs/man/nng_http_res_alloc.3http.adoc +++ b/docs/man/nng_http_res_alloc.3http.adoc @@ -28,8 +28,8 @@ int nng_http_res_alloc(nng_http_res **resp); The `nng_http_res_alloc()` function allocates a new HTTP response structure and stores a pointer to it in __resp__. The response will be initialized -with status code 200 (`NNG_HTTP_STATUS_OK`), and a reason phrase of "OK", -and HTTP protocol version "HTTP/1.1". +with status code 200 (`NNG_HTTP_STATUS_OK`), and a reason phrase of `"OK`", +and HTTP protocol version `"HTTP/1.1`". TIP: When an error response is needed, consider using `<>` instead. @@ -59,6 +59,7 @@ This function returns 0 on success, and non-zero otherwise. <>, <>, <>, +<>, <>, <>, <>, diff --git a/docs/man/nng_http_res_free.3http.adoc b/docs/man/nng_http_res_free.3http.adoc index 0c7f2445..e97f0be6 100644 --- a/docs/man/nng_http_res_free.3http.adoc +++ b/docs/man/nng_http_res_free.3http.adoc @@ -28,6 +28,9 @@ void nng_http_res_free(nng_http_res *req); The `nng_http_res_free()` function deallocates the HTTP response structure _res_ entirely. +TIP: Instead of freeing and reallocating response structures, it is possible +to reuse _res_ with `<>`. + == RETURN VALUES None. @@ -39,5 +42,6 @@ None. == SEE ALSO [.text-left] -<>, +<>, +<>, <> diff --git a/docs/man/nng_http_res_reset.3http.adoc b/docs/man/nng_http_res_reset.3http.adoc new file mode 100644 index 00000000..f33a0207 --- /dev/null +++ b/docs/man/nng_http_res_reset.3http.adoc @@ -0,0 +1,44 @@ += nng_http_res_reset(3http) +// +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV +// +// This document is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +== NAME + +nng_http_res_reset - reset HTTP response structure + +== SYNOPSIS + +[source, c] +---- +#include +#include + +void nng_http_res_reset(nng_http_res *res); +---- + +== DESCRIPTION + +The `nng_http_res_reset()` function resets the response __res__ so that it +is just as if it had been freshly allocated with +`<>`. + +== RETURN VALUES + +None. + +== ERRORS + +None. + +== SEE ALSO + +[.text-left] +<>, +<> -- cgit v1.2.3-70-g09d2