summaryrefslogtreecommitdiffstats
path: root/test/nanohttp.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/nanohttp.c')
-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;
+}