summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorGravatar snowdrop2004-09-19 07:05:01 +0000
committerGravatar snowdrop2004-09-19 07:05:01 +0000
commitd2c445f5d7cf21606c9878bff3e4046c283944df (patch)
treec562922b592bc3359a9dd12a671eff2974829592 /examples
parent6ea7f7e0961d05c5f0d995eecc785d1fd1e96b6f (diff)
downloadcsoap-d2c445f5d7cf21606c9878bff3e4046c283944df.tar.gz
csoap-d2c445f5d7cf21606c9878bff3e4046c283944df.tar.bz2
Added http stream feature (only input stream yet)
Added DIME "client" support (very experimental)
Diffstat (limited to 'examples')
-rw-r--r--examples/csoap/simpleserver.c5
-rw-r--r--examples/nanohttp/httpget.c18
-rw-r--r--examples/nanohttp/postserver.c63
3 files changed, 60 insertions, 26 deletions
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index 85ea78f..a5a3318 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleserver.c,v 1.8 2004/09/13 07:12:33 snowdrop Exp $
+ * $Id: simpleserver.c,v 1.9 2004/09/19 07:05:01 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003 Ferhat Ayaz
@@ -88,4 +88,5 @@ int main(int argc, char *argv[])
soap_server_destroy();
return 0;
-} \ No newline at end of file
+}
+
diff --git a/examples/nanohttp/httpget.c b/examples/nanohttp/httpget.c
index 319ff7f..e70469d 100644
--- a/examples/nanohttp/httpget.c
+++ b/examples/nanohttp/httpget.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: httpget.c,v 1.3 2004/08/26 17:02:24 rans Exp $
+* $Id: httpget.c,v 1.4 2004/09/19 07:05:03 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -23,19 +23,10 @@
******************************************************************/
#include <nanohttp/nanohttp-client.h>
-#ifdef WIN32
-#include <stdafx.h>
-#include <malloc.h>
-#else
#include <stdio.h>
-#endif
-#ifdef WIN32
-int _tmain(int argc, _TCHAR* argv[])
-#else
int main(int argc, char *argv[])
-#endif
{
httpc_conn_t *conn;
hresponse_t *res;
@@ -47,6 +38,11 @@ int main(int argc, char *argv[])
}
log_set_level(HLOG_VERBOSE);
+ if (httpc_init(argc, argv))
+ {
+ log_error1("Can not init httpc");
+ return 1;
+ }
conn = httpc_new();
res = httpc_get(conn, argv[1]);
@@ -75,4 +71,4 @@ int main(int argc, char *argv[])
httpc_free(conn);
return 0;
-} \ No newline at end of file
+}
diff --git a/examples/nanohttp/postserver.c b/examples/nanohttp/postserver.c
index 2a813b5..a28dc20 100644
--- a/examples/nanohttp/postserver.c
+++ b/examples/nanohttp/postserver.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: postserver.c,v 1.2 2004/08/26 17:02:24 rans Exp $
+* $Id: postserver.c,v 1.3 2004/09/19 07:05:03 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C (example)
* Copyright (C) 2003 Ferhat Ayaz
@@ -23,29 +23,70 @@
******************************************************************/
#include <nanohttp/nanohttp-server.h>
-#ifdef WIN32
-#include <stdafx.h>
-#include <malloc.h>
-#else
#include <stdio.h>
-#endif
+
+static
+void _print_binary_ascii(int n)
+{
+ int i,c=0;
+ char ascii[36];
+
+ for (i=0;i<32;i++) {
+ ascii[34-i-c] = (n & (1<<i))?'1':'0';
+ if ((i+1)%8 == 0) {
+ c++;
+ ascii[i+c] = ' ';
+ }
+ }
+
+ ascii[35]='\0';
+
+ log_verbose2("%s", ascii);
+}
+
+
+static
+void _print_binary_ascii2(unsigned char n)
+{
+ int i,c=0;
+ char ascii[9];
+
+ for (i=0;i<8;i++) {
+ ascii[7-i] = (n & (1<<i))?'1':'0';
+ }
+
+ ascii[8]='\0';
+
+ log_verbose2("%s", ascii);
+}
+
/*
SERVICE: http://host:port/postserver
*/
void post_service(httpd_conn_t *conn, hrequest_t *req)
{
- char *postdata;
+ unsigned char *postdata;
long received;
+ unsigned int tmp;
+ char buffer[15];
postdata = httpd_get_postdata(conn, req, &received, -1);
if (postdata != NULL) {
httpd_send_header(conn, 200, "OK", NULL);
- hsocket_send(conn->sock, "<html><body>");
- hsocket_send(conn->sock, "<h3>You Posted:</h3><hr>");
+ hsocket_send(conn->sock, "<html><body>\n");
+ hsocket_send(conn->sock, "<h3>You Posted:</h3><hr>\n");
hsocket_nsend(conn->sock, postdata, received);
+ hsocket_send(conn->sock, "<h3>Received size</h3><hr>\n");
+ sprintf(buffer, "%d", received);
+ hsocket_send(conn->sock, buffer);
hsocket_send(conn->sock, "</body></html>");
+
+ _print_binary_ascii2(postdata[0]);
+ _print_binary_ascii2(postdata[1]);
+ _print_binary_ascii2(postdata[2]);
+ _print_binary_ascii2(postdata[3]);
free(postdata);
} else {
@@ -62,11 +103,7 @@ void post_service(httpd_conn_t *conn, hrequest_t *req)
}
-#ifdef WIN32
-int _tmain(int argc, _TCHAR* argv[])
-#else
int main(int argc, char *argv[])
-#endif
{
log_set_level(HLOG_VERBOSE);