summaryrefslogtreecommitdiffstats
path: root/examples/nanohttp
diff options
context:
space:
mode:
authorGravatar m0gg2006-11-19 09:40:14 +0000
committerGravatar m0gg2006-11-19 09:40:14 +0000
commit949a8d0b46d6baa9f42c2f8c3bd5e3bdc3596cbd (patch)
tree1dfd1fd7cc3cb62bf300ae62ad306a66e674dc20 /examples/nanohttp
parentaa366f7be60c02168422bb713ef0e5a447bf07ea (diff)
downloadcsoap-949a8d0b46d6baa9f42c2f8c3bd5e3bdc3596cbd.tar.gz
csoap-949a8d0b46d6baa9f42c2f8c3bd5e3bdc3596cbd.tar.bz2
nanohttp admin patch; code cleanup
Diffstat (limited to 'examples/nanohttp')
-rw-r--r--examples/nanohttp/http_client.c15
-rw-r--r--examples/nanohttp/http_server.c22
2 files changed, 26 insertions, 11 deletions
diff --git a/examples/nanohttp/http_client.c b/examples/nanohttp/http_client.c
index c454fd7..d2ff4c9 100644
--- a/examples/nanohttp/http_client.c
+++ b/examples/nanohttp/http_client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: http_client.c,v 1.2 2006/07/09 16:24:19 snowdrop Exp $
+* $Id: http_client.c,v 1.3 2006/11/19 09:40:14 m0gg Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -23,9 +23,16 @@
******************************************************************/
#include <stdio.h>
#include <string.h>
-
-#include <nanohttp/nanohttp-logging.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+
+#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-socket.h>
+#include <nanohttp/nanohttp-stream.h>
+#include <nanohttp/nanohttp-request.h>
+#include <nanohttp/nanohttp-response.h>
#include <nanohttp/nanohttp-client.h>
+#include <nanohttp/nanohttp-logging.h>
#define MAX_BUFFER_SIZE 1024
@@ -38,7 +45,7 @@ static char *password = NULL;
static void show_response(hresponse_t *res) {
- byte_t buffer[MAX_BUFFER_SIZE+1];
+ unsigned char buffer[MAX_BUFFER_SIZE+1];
int read;
if (!res) {
diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c
index 348a1d7..5801312 100644
--- a/examples/nanohttp/http_server.c
+++ b/examples/nanohttp/http_server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: http_server.c,v 1.4 2006/07/09 16:24:19 snowdrop Exp $
+* $Id: http_server.c,v 1.5 2006/11/19 09:40:14 m0gg Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -21,11 +21,18 @@
*
* Email: hero@persua.de
******************************************************************/
+#include <sys/time.h>
#include <stdio.h>
#include <string.h>
+#include <netinet/in.h>
-#include <nanohttp/nanohttp-logging.h>
+#include <nanohttp/nanohttp-common.h>
+#include <nanohttp/nanohttp-socket.h>
+#include <nanohttp/nanohttp-stream.h>
+#include <nanohttp/nanohttp-request.h>
+#include <nanohttp/nanohttp-response.h>
#include <nanohttp/nanohttp-server.h>
+#include <nanohttp/nanohttp-logging.h>
static int simple_authenticator(hrequest_t *req, const char *user, const char *password)
{
@@ -133,6 +140,7 @@ static void root_service(httpd_conn_t *conn, hrequest_t *req)
"<li><a href=\"/secure\">Secure service</a> (try: bob/builder)</li>"
"<li><a href=\"/headers\">Request headers</a></li>"
"<li><a href=\"/not_existent\">The default service</a></li>"
+ "<li><a href=\"/nhttp\">Admin page</a> (try -NHTTPDadmin on the command line)</li>"
"</ul>"
"</body>"
"</html>");
@@ -146,31 +154,31 @@ int main(int argc, char *argv[])
if (httpd_init(argc, argv)) {
- fprintf(stderr, "Can not init httpd");
+ fprintf(stderr, "Cannot init httpd");
return 1;
}
if (!httpd_register("/", root_service)) {
- fprintf(stderr, "Can not register service");
+ fprintf(stderr, "Cannot register service");
return 1;
}
if (!httpd_register_secure("/secure", secure_service, simple_authenticator)) {
- fprintf(stderr, "Can not register secure service");
+ fprintf(stderr, "Cannot register secure service");
return 1;
}
if (!httpd_register("/headers", headers_service)) {
- fprintf(stderr, "Can not register headers service");
+ fprintf(stderr, "Cannot register headers service");
return 1;
}
if (!httpd_register_default("/error", default_service)) {
- fprintf(stderr, "Can not register default service");
+ fprintf(stderr, "Cannot register default service");
return 1;
}