From 579048eaf89784ec1da8592d96311fafd49aea1a Mon Sep 17 00:00:00 2001 From: sijanec Date: Thu, 1 Apr 2021 23:30:37 +0200 Subject: initial commit --- test/nanohttp.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/nanohttp.c (limited to 'test') diff --git a/test/nanohttp.c b/test/nanohttp.c new file mode 100644 index 0000000..78d9fda --- /dev/null +++ b/test/nanohttp.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#define UA "Nokia WAP Gateway 4.1 CD1/ECD13_D/4.1.04)" +int main (int argc, char ** argv) { + if (argc < 1+1) { + fprintf(stderr, "%s \n", argv[0]); + return 1; + } + char * contentType = NULL; + char * redir = NULL; + int readstatus = 0; + char buf[4096]; + /* xmlNanoHTTPInit(); */ + void * r = xmlNanoHTTPMethodRedir(argv[1], "GET", NULL /* inp */, &contentType, &redir, "User-Agent: " UA "\r\n", 0 /* inplen */); + if (!r) { + fprintf(stderr, "!r\n"); + return 1; + } + if (xmlNanoHTTPReturnCode(r) != 200) + fprintf(stderr, "xmlNanoHTTPReturnCode(r) != 200\n"); + while ((readstatus = xmlNanoHTTPRead(r, buf, 4096)) > 1) + write(1, buf, readstatus); + if (readstatus == -1) + fprintf(stderr, "readstatus == -1\n"); + xmlNanoHTTPClose(r); + free(contentType); + free(redir); + /* xmlNanoHTTPCleanup(); */ + return 0; +} -- cgit v1.2.3