diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-01-29 13:27:52 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-01-29 13:27:52 -0800 |
| commit | 5914e40c2ff7fcf346c90705785f3fb7650a9fdc (patch) | |
| tree | d769f4110a76679df0ffcf2b4e953bb9b9f3687d /tests | |
| parent | e32022c8085fc6b05ed690f9b4b49536d8df13b1 (diff) | |
| download | nng-5914e40c2ff7fcf346c90705785f3fb7650a9fdc.tar.gz nng-5914e40c2ff7fcf346c90705785f3fb7650a9fdc.tar.bz2 nng-5914e40c2ff7fcf346c90705785f3fb7650a9fdc.zip | |
Expose scatter/gather I/O vectors; we will use for HTTP API.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/httpclient.c | 13 | ||||
| -rw-r--r-- | tests/httpserver.c | 16 |
2 files changed, 16 insertions, 13 deletions
diff --git a/tests/httpclient.c b/tests/httpclient.c index b58dc81f..f965cf2d 100644 --- a/tests/httpclient.c +++ b/tests/httpclient.c @@ -83,6 +83,7 @@ TestMain("HTTP Client", { void * data; const char *cstr; size_t sz; + nng_iov iov; cstr = nni_http_res_get_header( res, "Content-Length"); @@ -94,16 +95,16 @@ TestMain("HTTP Client", { So(data != NULL); Reset({ nni_free(data, sz); }); - iaio->a_niov = 1; - iaio->a_iov[0].iov_len = sz; - iaio->a_iov[0].iov_buf = data; + iov.iov_buf = data; + iov.iov_len = sz; + So(nng_aio_set_iov(aio, 1, &iov) == 0); - nni_aio_wait(iaio); + nng_aio_wait(aio); So(nng_aio_result(aio) == 0); nni_http_read_full(http, iaio); - nni_aio_wait(iaio); - So(nni_aio_result(iaio) == 0); + nng_aio_wait(aio); + So(nng_aio_result(aio) == 0); nni_sha1(data, sz, digest); So(memcmp(digest, utf8_sha1sum, 20) == 0); diff --git a/tests/httpserver.c b/tests/httpserver.c index f7ab377c..062f964a 100644 --- a/tests/httpserver.c +++ b/tests/httpserver.c @@ -84,10 +84,11 @@ httpget(const char *addr, void **datap, size_t *sizep, uint16_t *statp, } if (clen > 0) { - data = nni_alloc(clen); - aio->a_niov = 1; - aio->a_iov[0].iov_len = clen; - aio->a_iov[0].iov_buf = data; + nng_iov iov; + data = nni_alloc(clen); + iov.iov_buf = data; + iov.iov_len = clen; + nni_aio_set_iov(aio, 1, &iov); nni_http_read_full(h, aio); nni_aio_wait(aio); if ((rv = nni_aio_result(aio)) != 0) { @@ -212,6 +213,7 @@ TestMain("HTTP Client", { Convey("Valid data works", { char chunk[256]; const void *ptr; + nng_iov iov; So(nni_http_req_set_method(req, "GET") == 0); So(nni_http_req_set_version(req, "HTTP/1.1") == @@ -236,9 +238,9 @@ TestMain("HTTP Client", { So(ptr != NULL); So(atoi(ptr) == strlen(doc1)); - aio->a_niov = 1; - aio->a_iov[0].iov_len = strlen(doc1); - aio->a_iov[0].iov_buf = (void *) chunk; + iov.iov_len = strlen(doc1); + iov.iov_buf = chunk; + So(nni_aio_set_iov(aio, 1, &iov) == 0); nni_http_read_full(h, aio); nni_aio_wait(aio); So(nni_aio_result(aio) == 0); |
