aboutsummaryrefslogtreecommitdiff
path: root/docs/ref/api/http.md
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2025-01-12 14:43:31 -0800
committerGarrett D'Amore <garrett@damore.org>2025-01-12 14:43:31 -0800
commit2ddaecdadb8a931188b3f3e6b8ad43b9cba45d0f (patch)
treeddab0fbc8bb631fc31c233e09cd83a561988158d /docs/ref/api/http.md
parentd88484cafbf973d55dc95b7edcae5064efa8bad0 (diff)
downloadnng-2ddaecdadb8a931188b3f3e6b8ad43b9cba45d0f.tar.gz
nng-2ddaecdadb8a931188b3f3e6b8ad43b9cba45d0f.tar.bz2
nng-2ddaecdadb8a931188b3f3e6b8ad43b9cba45d0f.zip
api: extend usage of nng_err
This replaces the int, and we will expand this further, as this makes it clear that the int is actually an error code and helps in debuggers that can provide symbolic values.
Diffstat (limited to 'docs/ref/api/http.md')
-rw-r--r--docs/ref/api/http.md25
1 files changed, 8 insertions, 17 deletions
diff --git a/docs/ref/api/http.md b/docs/ref/api/http.md
index 48b09300..da3d22d4 100644
--- a/docs/ref/api/http.md
+++ b/docs/ref/api/http.md
@@ -56,7 +56,7 @@ set when issuing the transaction.
### HTTP URI
```c
-int nng_http_set_uri(nng_http *conn, const char *uri, const char *query);
+nng_err nng_http_set_uri(nng_http *conn, const char *uri, const char *query);
const char *nng_http_get_uri(nng_http *conn);
```
@@ -76,7 +76,7 @@ will have any query concentated, for example "/api/get_user.cgi?name=garrett".
### HTTP Version
```c
-int nng_http_set_version(nng_http *conn, const char *version);
+nng_err nng_http_set_version(nng_http *conn, const char *version);
const char *nng_http_get_version(nng_http *conn);
```
@@ -210,8 +210,8 @@ The scan can be rest by setting _next_ to `NULL`.
### Modifying Headers
```c
-int nng_http_add_header(nng_http *conn, const char *key, const char *val);
-int nng_http_set_header(nng_http *conn, const char *key, const char *val);
+nng_err nng_http_add_header(nng_http *conn, const char *key, const char *val);
+nng_err nng_http_set_header(nng_http *conn, const char *key, const char *val);
void nng_http_del_header(nng_http *conn, const char *key);
```
@@ -323,7 +323,7 @@ They can be used to transfer request or response body data as well.
### Hijacking Connections
```c
-void nng_http_hijack(nng_http_conn *conn);
+nng_err nng_http_hijack(nng_http *conn);
```
TODO: This API will change to convert the conn into a stream object.
@@ -387,8 +387,8 @@ of its resources.
### Client TLS
```c
-int nng_http_client_get_tls(nng_http_client *client, nng_tls_config **tlsp);
-int nng_http_client_set_tls(nng_http_client *client, nng_tls_config *tls);
+nng_err nng_http_client_get_tls(nng_http_client *client, nng_tls_config **tlsp);
+nng_err nng_http_client_set_tls(nng_http_client *client, nng_tls_config *tls);
```
The {{i:`nng_http_client_get_tls`}} and {{i:`nng_http_client_set_tls`}} functions are used to
@@ -456,15 +456,6 @@ if ((rv = nng_aio_result(aio)) != 0) {
### Preparing a Transaction
-```c
-int nng_http_set_version(nng_http *conn, const char *version);
-int nng_http_set_uri(nng_http *conn, const char *uri);
-```
-
-The {{i:`nng_http_set_uri`}} function provides a URI for the transaction. This will be used to
-set the URI for the request. The URI typically appears like a path, starting with "/", although
-it may also contain a query string.
-
### Request Body
### Sending the Request
@@ -510,7 +501,7 @@ It does _not_ transfer any response body. To do that, use [`nng_http_read_all`]
### Submitting the Transaction
```c
-int nng_http_transact(nng_http *conn, nng_aio *aio);
+void nng_http_transact(nng_http *conn, nng_aio *aio);
```
The HTTP request is issued, and the response processed, asynchronously by the {{i:`nng_http_transact`}} function.