X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=blobdiff_plain;f=uclient-example.c;h=8c9d3e6d20e3304053c3a14e0cd454d052c5d81d;hp=64395faea8544832b8a3a08b365208cfc2960a9d;hb=3ddb765bd513a70d128810b65c3a45f81690782e;hpb=299b1af9c051248771537980ee2d16c29c61376d diff --git a/uclient-example.c b/uclient-example.c index 64395fa..8c9d3e6 100644 --- a/uclient-example.c +++ b/uclient-example.c @@ -15,17 +15,28 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include + #include #include +#include + #include "uclient.h" + static void example_header_done(struct uclient *cl) { struct blob_attr *cur; + char local[INET6_ADDRSTRLEN], remote[INET6_ADDRSTRLEN]; + int local_port, remote_port; int rem; + uclient_get_addr(local, &local_port, &cl->local_addr); + uclient_get_addr(remote, &remote_port, &cl->remote_addr); + + fprintf(stderr, "Connected: %s:%d -> %s:%d\n", + local, local_port, remote, remote_port); + printf("Headers (%d): \n", cl->status_code); blobmsg_for_each_attr(cur, cl->meta, rem) { printf("%s=%s\n", blobmsg_name(cur), (char *) blobmsg_data(cur)); @@ -138,13 +149,13 @@ int main(int argc, char **argv) uloop_init(); - cl = uclient_new(argv[0], &cb); + cl = uclient_new(argv[0], NULL, &cb); if (!cl) { fprintf(stderr, "Failed to allocate uclient context\n"); return 1; } - uclient_http_set_ssl_ctx(cl, ctx, verify); + uclient_http_set_ssl_ctx(cl, &ustream_ssl_ops, ctx, verify); example_request_sm(cl); uloop_run(); uloop_done();