summaryrefslogtreecommitdiffstats
path: root/nanohttp/nanohttp-request.c
diff options
context:
space:
mode:
authorGravatar snowdrop2006-02-27 22:26:01 +0000
committerGravatar snowdrop2006-02-27 22:26:01 +0000
commitb73c5d785a71edade3ba473cbb13ec57aaeec7ed (patch)
tree513989fcd640714bd6520d1d981aeb0bd391c267 /nanohttp/nanohttp-request.c
parentc734a9e1a4fc7418911d8c50817d619221d2cd42 (diff)
downloadcsoap-b73c5d785a71edade3ba473cbb13ec57aaeec7ed.tar.gz
csoap-b73c5d785a71edade3ba473cbb13ec57aaeec7ed.tar.bz2
- removes a memleak in examples/csoap/simpleserver.c say_hello
- adds various malloc error messages - does some libcsoap/*.c #include fixups - removes a memleak in libcsoap/soap-server.c soap_server_entry - removes the double free of SoapCtx->action (again!!!) - rewrites more or less cleanly hsocket_close - adds volatile keywords for thread shared data items - _httpd_parse_arguments cleanup - rwerites the _httpd_connection initialization - adds a call to pthread_attr_destroy in httpd_session_main - fixes a wrong loop initialization in _httpd_wait_for_emtpy_conn - fixes a memleak in httpd_session_main (req) - more sophisticated httpd_server example - HTTP authentication SEGfault without password fixed
Diffstat (limited to 'nanohttp/nanohttp-request.c')
-rwxr-xr-xnanohttp/nanohttp-request.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/nanohttp/nanohttp-request.c b/nanohttp/nanohttp-request.c
index 98880f2..1a3e998 100755
--- a/nanohttp/nanohttp-request.c
+++ b/nanohttp/nanohttp-request.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: nanohttp-request.c,v 1.10 2006/02/18 20:14:36 snowdrop Exp $
+* $Id: nanohttp-request.c,v 1.11 2006/02/27 22:26:02 snowdrop Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -25,24 +25,35 @@
#include <config.h>
#endif
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
#ifdef MEM_DEBUG
#include <utils/alloc.h>
#endif
-#include <nanohttp/nanohttp-common.h>
-#include <nanohttp/nanohttp-request.h>
-
-/* request stuff */
-
+#include "nanohttp-common.h"
+#include "nanohttp-request.h"
static hrequest_t *
hrequest_new()
{
- hrequest_t *req = (hrequest_t *) malloc(sizeof(hrequest_t));
+ hrequest_t *req;
+
+ if (!(req = (hrequest_t *) malloc(sizeof(hrequest_t)))) {
+
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
req->method = HTTP_REQUEST_GET;
req->version = HTTP_1_1;
@@ -147,7 +158,11 @@ _hrequest_parse_header(char *data)
/* create option pair */
if (opt_key != NULL)
{
- tmppair = (hpair_t *) malloc(sizeof(hpair_t));
+ if (!(tmppair = (hpair_t *) malloc(sizeof(hpair_t))))
+ {
+ log_error2("malloc failed (%s)", strerror(errno));
+ return NULL;
+ }
if (req->query == NULL)
{
@@ -161,11 +176,8 @@ _hrequest_parse_header(char *data)
/* fill hpairnode_t struct */
qpair->next = NULL;
- qpair->key = (char *) malloc(strlen(opt_key) + 1);
- qpair->value = (char *) malloc(strlen(opt_value) + 1);
-
- strcpy(qpair->key, opt_key);
- strcpy(qpair->value, opt_value);
+ qpair->key = strdup(opt_key);
+ qpair->value = strdup(opt_value);
}
}