From 5e5f814d63d4e00365b0ae726bc18831aa28e88f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 1 Feb 2018 16:48:20 -0800 Subject: fixes #174 Define public HTTP client API --- tests/httpclient.c | 11 +++++------ tests/httpserver.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/httpclient.c b/tests/httpclient.c index f26674f6..2438ab4c 100644 --- a/tests/httpclient.c +++ b/tests/httpclient.c @@ -17,7 +17,6 @@ // Basic HTTP client tests. #include "core/nng_impl.h" -#include "supplemental/http/http.h" #include "supplemental/sha1/sha1.h" const uint8_t utf8_sha1sum[20] = { 0x54, 0xf3, 0xb8, 0xbb, 0xfe, 0xda, 0x6f, @@ -31,7 +30,7 @@ TestMain("HTTP Client", { Convey("Given a TCP connection to httpbin.org", { nng_aio * aio; - nni_http_client *cli; + nng_http_client *cli; nng_http_conn * http; nng_url * url; @@ -39,13 +38,13 @@ TestMain("HTTP Client", { So(nng_url_parse(&url, "http://httpbin.org/encoding/utf8") == 0); - So(nni_http_client_init(&cli, url) == 0); - nni_http_client_connect(cli, aio); + So(nng_http_client_alloc(&cli, url) == 0); + nng_http_client_connect(cli, aio); nng_aio_wait(aio); So(nng_aio_result(aio) == 0); - http = nni_aio_get_output(aio, 0); + http = nng_aio_get_output(aio, 0); Reset({ - nni_http_client_fini(cli); + nng_http_client_free(cli); nng_http_conn_close(http); nng_aio_free(aio); nng_url_free(url); diff --git a/tests/httpserver.c b/tests/httpserver.c index 1008058f..a62bae25 100644 --- a/tests/httpserver.c +++ b/tests/httpserver.c @@ -17,7 +17,6 @@ // Basic HTTP server tests. #include "core/nng_impl.h" -#include "supplemental/http/http.h" const char *doc1 = "Someone is home!"; const char *doc2 = "This is a text file."; @@ -35,23 +34,23 @@ httpdo(nng_url *url, nng_http_req *req, nng_http_res *res, void **datap, { int rv; nng_aio * aio = NULL; - nni_http_client *cli = NULL; + nng_http_client *cli = NULL; nng_http_conn * h = NULL; size_t clen = 0; void * data = NULL; const char * ptr; if (((rv = nng_aio_alloc(&aio, NULL, NULL)) != 0) || - ((rv = nni_http_client_init(&cli, url)) != 0)) { + ((rv = nng_http_client_alloc(&cli, url)) != 0)) { goto fail; } - nni_http_client_connect(cli, aio); + nng_http_client_connect(cli, aio); nng_aio_wait(aio); - if ((rv = nni_aio_result(aio)) != 0) { + if ((rv = nng_aio_result(aio)) != 0) { goto fail; } - h = nni_aio_get_output(aio, 0); + h = nng_aio_get_output(aio, 0); nng_http_conn_write_req(h, req, aio); nng_aio_wait(aio); @@ -94,7 +93,7 @@ fail: nng_http_conn_close(h); } if (cli != NULL) { - nni_http_client_fini(cli); + nng_http_client_free(cli); } return (rv); @@ -191,13 +190,13 @@ TestMain("HTTP Server", { So(nng_http_server_start(s) == 0); Convey("We can connect a client to it", { - nni_http_client *cli; + nng_http_client *cli; nng_http_conn * h; nng_http_req * req; nng_http_res * res; - So(nni_http_client_init(&cli, url) == 0); - nni_http_client_connect(cli, aio); + So(nng_http_client_alloc(&cli, url) == 0); + nng_http_client_connect(cli, aio); nng_aio_wait(aio); So(nng_aio_result(aio) == 0); @@ -207,7 +206,7 @@ TestMain("HTTP Server", { So(nng_http_res_alloc(&res) == 0); Reset({ - nni_http_client_fini(cli); + nng_http_client_free(cli); nng_http_conn_close(h); nng_http_req_free(req); nng_http_res_free(res); -- cgit v1.2.3-70-g09d2