Skip to content

Commit

Permalink
http: direct read and write API
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Jan 8, 2025
1 parent b75e784 commit 14b0c42
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 406 deletions.
11 changes: 6 additions & 5 deletions demo/http_client/http_client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2018 Staysail Systems, Inc. <[email protected]>
// Copyright 2025 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
//
// This software is supplied under the terms of the MIT License, a
Expand Down Expand Up @@ -66,10 +66,12 @@ main(int argc, char **argv)
}

if (((rv = nng_init(NULL)) != 0) ||
((rv = nng_aio_alloc(&aio, NULL, NULL)) != 0) ||
((rv = nng_url_parse(&url, argv[1])) != 0) ||
((rv = nng_http_client_alloc(&client, url)) != 0) ||
((rv = nng_aio_alloc(&aio, NULL, NULL)) != 0)) {
fatal(rv);
return 1;
}

// Start connection process...
Expand Down Expand Up @@ -105,10 +107,9 @@ main(int argc, char **argv)
fatal(rv);
}

if (nng_http_res_get_status(res) != NNG_HTTP_STATUS_OK) {
if (nng_http_get_status(conn) != NNG_HTTP_STATUS_OK) {
fprintf(stderr, "HTTP Server Responded: %d %s\n",
nng_http_res_get_status(res),
nng_http_res_get_reason(res));
nng_http_get_status(conn), nng_http_get_reason(conn));
}

// This only supports regular transfer encoding (no Chunked-Encoding,
Expand All @@ -134,7 +135,7 @@ main(int argc, char **argv)
nng_aio_set_iov(aio, 1, &iov);

// Now attempt to receive the data.
nng_http_conn_read_all(conn, aio);
nng_http_read_all(conn, aio);

// Wait for it to complete.
nng_aio_wait(aio);
Expand Down
2 changes: 1 addition & 1 deletion docs/man/libnng.3.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ and connections.
|===
|xref:nng_http_conn_close.3http.adoc[nng_http_conn_close()]|close HTTP connection
|xref:nng_http_conn_read.3http.adoc[nng_http_conn_read()]|read from HTTP connection
|xref:nng_http_conn_read_all.3http.adoc[nng_http_conn_read_all()]|read all from HTTP connection
|xref:nng_http_read_all.3http.adoc[nng_http_conn_all()]|read all from HTTP connection
|xref:nng_http_conn_read_req.3http.adoc[nng_http_conn_read_req()]|read HTTP request
|xref:nng_http_conn_read_res.3http.adoc[nng_http_conn_read_res()]|read HTTP response
|xref:nng_http_conn_write.3http.adoc[nng_http_conn_write()]|write to HTTP connection
Expand Down
77 changes: 0 additions & 77 deletions docs/man/nng_http_conn_read.3http.adoc

This file was deleted.

78 changes: 0 additions & 78 deletions docs/man/nng_http_conn_read_all.3http.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/man/nng_http_conn_read_req.3http.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ associated with _conn_, including all of the related headers.
NOTE: Any HTTP entity/body data associated with the request is *not* read
automatically.
The caller should use
xref:nng_http_conn_read_all.3http.adoc[`nng_http_conn_read_all()`]
xref:nng_http_read_all.3http.adoc[`nng_http_read_all()`]
to read the entity data, based on the details of the request itself.

This function returns immediately, with no return value.
Expand Down
76 changes: 0 additions & 76 deletions docs/man/nng_http_conn_write.3http.adoc

This file was deleted.

96 changes: 0 additions & 96 deletions docs/man/nng_http_conn_write_all.3http.adoc

This file was deleted.

Loading

0 comments on commit 14b0c42

Please sign in to comment.