summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorsijanec <anton@sijanec.eu>2021-04-01 23:30:37 +0200
committersijanec <anton@sijanec.eu>2021-04-01 23:30:37 +0200
commit579048eaf89784ec1da8592d96311fafd49aea1a (patch)
tree61bf0c50c656f2b16ed8901ec3b07fb468ffb916 /test
downloadsear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar.gz
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar.bz2
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar.lz
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar.xz
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.tar.zst
sear.c-579048eaf89784ec1da8592d96311fafd49aea1a.zip
Diffstat (limited to 'test')
-rw-r--r--test/nanohttp.c32
1 files changed, 32 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <libxml/nanohttp.h>
+#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 <URL>\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;
+}