From 5502aff768e5cbc3bbd05e067bc0dfc456770f86 Mon Sep 17 00:00:00 2001 From: m0gg Date: Mon, 1 Jan 2007 22:54:46 +0000 Subject: Header parsing error solved --- examples/csoap/echoattachments-client.c | 13 +++++++------ examples/csoap/echoattachments-server.c | 9 +++++---- examples/nanohttp/http_server.c | 31 ++++++++++--------------------- 3 files changed, 22 insertions(+), 31 deletions(-) (limited to 'examples') diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c index fbee05e..4ad908e 100755 --- a/examples/csoap/echoattachments-client.c +++ b/examples/csoap/echoattachments-client.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-client.c,v 1.16 2006/11/30 14:23:59 m0gg Exp $ + * $Id: echoattachments-client.c,v 1.17 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -101,6 +101,7 @@ compareFiles(const char *received, const char *sent) fclose(f1); fclose(f2); + return; } int @@ -122,7 +123,7 @@ main(int argc, char **argv) err = soap_client_init_args(argc, argv); if (err != H_OK) { - printf("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err)); + printf("[%d] %s():%s \n", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); return 1; } @@ -132,7 +133,7 @@ main(int argc, char **argv) err = soap_ctx_new_with_method(urn, method, &ctx); if (err != H_OK) { - printf("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err)); + printf("[%d] %s():%s \n", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); return 1; } @@ -142,7 +143,7 @@ main(int argc, char **argv) err = soap_ctx_add_file(ctx, argv[1], "application/octet-stream", href); if (err != H_OK) { - printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); + printf("%s():%s [%d]\n", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } @@ -161,7 +162,7 @@ main(int argc, char **argv) if (err != H_OK) { - printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); + printf("%s():%s [%d]\n", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } @@ -179,7 +180,7 @@ main(int argc, char **argv) } else { - printf("No attachments!"); + printf("No attachments!\n"); xmlDocDump(stdout, ctx2->env->root->doc); } diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c index ea45aa8..e6b4872 100755 --- a/examples/csoap/echoattachments-server.c +++ b/examples/csoap/echoattachments-server.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-server.c,v 1.12 2006/11/25 15:06:57 m0gg Exp $ + * $Id: echoattachments-server.c,v 1.13 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -57,6 +57,7 @@ echo_attachments(struct SoapCtx * req, struct SoapCtx * res) { for (part = req->attachments->parts; part != NULL; part = part->next) { + printf("attaching \"%s\"\n", part->filename); soap_ctx_add_file(res, part->filename, part->content_type, href); soap_env_add_attachment(res->env, "echoFile", href); } @@ -76,7 +77,7 @@ main(int argc, char **argv) err = soap_server_init_args(argc, argv); if (err != H_OK) { - printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); + printf("%s():%s [%d]\n", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); return 1; } @@ -85,10 +86,10 @@ main(int argc, char **argv) soap_router_register_service(router, echo_attachments, method, urn); soap_server_register_router(router, url); - log_info1("send SIGTERM to shutdown"); + printf("send SIGTERM to shutdown"); soap_server_run(); - log_info1("shutting down\n"); + printf("shutting down\n"); soap_server_destroy(); return 0; diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c index a00c982..052aec1 100644 --- a/examples/nanohttp/http_server.c +++ b/examples/nanohttp/http_server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_server.c,v 1.12 2006/12/10 12:23:45 m0gg Exp $ +* $Id: http_server.c,v 1.13 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -22,6 +22,7 @@ * Email: hero@persua.de ******************************************************************/ #include +#include #include #include @@ -63,29 +64,20 @@ static void secure_service(httpd_conn_t *conn, struct hrequest_t *req) static void default_service(httpd_conn_t *conn, struct hrequest_t *req) { - httpd_send_header(conn, 404, HTTP_STATUS_404_REASON_PHRASE); - http_output_stream_write_string(conn->out, - "" - "" - "Default error page" - "" - "" - "

Default error page

" - "
"); + char buf[512]; - http_output_stream_write_string(conn->out, req->path); + snprintf(buf, 512, "Resource \"%s\" not found", req->path); - http_output_stream_write_string(conn->out, " cannot be found" - "
" - "" - ""); + httpd_send_not_found(conn, buf); return; -} +} static void headers_service(httpd_conn_t *conn, struct hrequest_t *req) { hpair_t *walker; + char buf[512]; + int len; httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, @@ -99,11 +91,8 @@ static void headers_service(httpd_conn_t *conn, struct hrequest_t *req) for (walker=req->header; walker; walker=walker->next) { - http_output_stream_write_string(conn->out, "
  • "); - http_output_stream_write_string(conn->out, walker->key); - http_output_stream_write_string(conn->out, " = "); - http_output_stream_write_string(conn->out, walker->value); - http_output_stream_write_string(conn->out, "
  • "); + len = snprintf(buf, 512, "
  • %s: %s
  • ", walker->key, walker->value); + http_output_stream_write(conn->out, buf, len); } http_output_stream_write_string(conn->out, -- cgit v1.1-32-gdbae