diff options
Diffstat (limited to 'nanohttp')
-rw-r--r-- | nanohttp/nanohttp-admin.c | 12 | ||||
-rw-r--r-- | nanohttp/nanohttp-client.c | 4 | ||||
-rw-r--r-- | nanohttp/nanohttp-common.c | 20 | ||||
-rw-r--r-- | nanohttp/nanohttp-server.c | 32 | ||||
-rw-r--r-- | nanohttp/nanohttp-server.h | 33 |
5 files changed, 57 insertions, 44 deletions
diff --git a/nanohttp/nanohttp-admin.c b/nanohttp/nanohttp-admin.c index 3dbdbd6..060cbb8 100644 --- a/nanohttp/nanohttp-admin.c +++ b/nanohttp/nanohttp-admin.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-admin.c,v 1.11 2006/12/31 17:24:22 m0gg Exp $ +* $Id: nanohttp-admin.c,v 1.12 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -68,9 +68,9 @@ _httpd_admin_send_title(httpd_conn_t *conn, const char *title) "</style>"); http_output_stream_write_string(conn->out, - "</head>" - "<body>" - "<span class=\"logo\">nhttpd</span> "); + "</head>" + "<body>" + "<span class=\"logo\">nhttpd</span> "); http_output_stream_write_string(conn->out, title); http_output_stream_write_string(conn->out, "<hr />"); @@ -80,7 +80,9 @@ _httpd_admin_send_title(httpd_conn_t *conn, const char *title) static inline void _httpd_admin_send_footer(httpd_conn_t *conn) { - http_output_stream_write_string(conn->out, "</body></html>"); + http_output_stream_write_string(conn->out, + "</body>" + "</html>"); return; } diff --git a/nanohttp/nanohttp-client.c b/nanohttp/nanohttp-client.c index 00bf7c7..472c58f 100644 --- a/nanohttp/nanohttp-client.c +++ b/nanohttp/nanohttp-client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-client.c,v 1.52 2007/01/01 15:29:48 m0gg Exp $ +* $Id: nanohttp-client.c,v 1.53 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -390,7 +390,7 @@ _httpc_talk_to_server(hreq_method_t method, httpc_conn_t * conn, const char *url httpc_set_header(conn, HEADER_HOST, conn->url->host); ssl = conn->url->protocol == PROTOCOL_HTTPS ? 1 : 0; - log_error4("ssl = %i (%i %i)", ssl, conn->url->protocol, PROTOCOL_HTTPS); + log_verbose4("ssl = %i (%i %i)", ssl, conn->url->protocol, PROTOCOL_HTTPS); /* Open connection */ if ((status = hsocket_open(conn->sock, conn->url->host, conn->url->port, ssl)) != H_OK) diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c index 9b5015e..de17bfe 100644 --- a/nanohttp/nanohttp-common.c +++ b/nanohttp/nanohttp-common.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-common.c,v 1.37 2006/12/16 15:55:24 m0gg Exp $ +* $Id: nanohttp-common.c,v 1.38 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -71,8 +71,7 @@ hpairnode_new(const char *key, const char *value, hpair_t * next) if (key != NULL) { - pair->key = (char *) malloc(strlen(key) + 1); - strcpy(pair->key, key); + pair->key = strdup(key); } else { @@ -81,8 +80,7 @@ hpairnode_new(const char *key, const char *value, hpair_t * next) if (value != NULL) { - pair->value = (char *) malloc(strlen(value) + 1); - strcpy(pair->value, value); + pair->value = strdup(value); } else { @@ -99,7 +97,6 @@ hpairnode_parse(const char *str, const char *delim, hpair_t * next) { hpair_t *pair; char *key, *value; - int c; pair = (hpair_t *) malloc(sizeof(hpair_t)); pair->key = ""; @@ -110,19 +107,18 @@ hpairnode_parse(const char *str, const char *delim, hpair_t * next) if (key != NULL) { - pair->key = (char *) malloc(strlen(key) + 1); - strcpy(pair->key, key); + pair->key = strdup(key); } if (value != NULL) { - for (c = 0; value[c] == ' '; c++); /* skip white space */ - pair->value = (char *) malloc(strlen(&value[c]) + 1); - strcpy(pair->value, &value[c]); + /* skip white space */ + for (; *value == ' '; value++) ; + + pair->value = strdup(value); } return pair; } - hpair_t * hpairnode_copy(const hpair_t * src) { diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c index 9e2af45..e7fe6d6 100644 --- a/nanohttp/nanohttp-server.c +++ b/nanohttp/nanohttp-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-server.c,v 1.79 2007/01/01 15:29:48 m0gg Exp $ +* $Id: nanohttp-server.c,v 1.80 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -549,18 +549,6 @@ _httpd_send_html_message(httpd_conn_t *conn, int reason, const char *phrase, con } herror_t -httpd_send_internal_error(httpd_conn_t * conn, const char *msg) -{ - return _httpd_send_html_message(conn, 500, HTTP_STATUS_500_REASON_PHRASE, msg); -} - -herror_t -httpd_send_not_implemented(httpd_conn_t *conn, const char *msg) -{ - return _httpd_send_html_message(conn, 501, HTTP_STATUS_501_REASON_PHRASE, msg); -} - -herror_t httpd_send_bad_request(httpd_conn_t *conn, const char *msg) { return _httpd_send_html_message(conn, 400, HTTP_STATUS_400_REASON_PHRASE, msg); @@ -577,6 +565,24 @@ httpd_send_unauthorized(httpd_conn_t *conn, const char *realm) return _httpd_send_html_message(conn, 401, HTTP_STATUS_401_REASON_PHRASE, "Unauthorized request logged"); } +herror_t +httpd_send_not_found(httpd_conn_t *conn, const char *msg) +{ + return _httpd_send_html_message(conn, 404, HTTP_STATUS_404_REASON_PHRASE, msg); +} + +herror_t +httpd_send_internal_error(httpd_conn_t *conn, const char *msg) +{ + return _httpd_send_html_message(conn, 500, HTTP_STATUS_500_REASON_PHRASE, msg); +} + +herror_t +httpd_send_not_implemented(httpd_conn_t *conn, const char *msg) +{ + return _httpd_send_html_message(conn, 501, HTTP_STATUS_501_REASON_PHRASE, msg); +} + static void _httpd_request_print(struct hrequest_t * req) { diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h index 53eb4a8..71c0370 100644 --- a/nanohttp/nanohttp-server.h +++ b/nanohttp/nanohttp-server.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-server.h,v 1.35 2007/01/01 18:58:05 m0gg Exp $ + * $Id: nanohttp-server.h,v 1.36 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -360,39 +360,48 @@ extern herror_t httpd_mime_end(httpd_conn_t * conn); /** * - * Send a minimalistic HTML error document with HTTP status 500. + * Send a minimalistic HTML error document with HTTP status 400. * - * @see HTTP_STATUS_500_REASON_PHRASE + * @see HTTP_STATUS_400_REASON_PHRASE * */ -extern herror_t httpd_send_internal_error(httpd_conn_t * conn, const char *msg); +extern herror_t httpd_send_bad_request(httpd_conn_t *conn, const char *msg); /** * - * Send a minimalistic HTML error document with HTTP status 501. + * Send a minimalistc HTML error document with HTTP status 401. * - * @see HTTP_STATUS_501_REASON_PHRASE + * @see HTTP_STATUS_401_REASON_PHRASE * */ -extern herror_t httpd_send_not_implemented(httpd_conn_t *conn, const char *msg); +extern herror_t httpd_send_unauthorized(httpd_conn_t *conn, const char *realm); /** * * Send a minimalistic HTML error document with HTTP status 404. * - * @see HTTP_STATUS_401_REASON_PHRASE + * @see HTTP_STATUS_404_REASON_PHRASE * */ -extern herror_t httpd_send_bad_request(httpd_conn_t *conn, const char *msg); +extern herror_t httpd_send_not_found(httpd_conn_t *conn, const char *msg); /** * - * Send a minimalistc HTML error document with HTTP status 401. + * Send a minimalistic HTML error document with HTTP status 500. * - * @see HTTP_STATUS_404_REASON_PHRASE + * @see HTTP_STATUS_500_REASON_PHRASE * */ -extern herror_t httpd_send_unauthorized(httpd_conn_t *conn, const char *realm); +extern herror_t httpd_send_internal_error(httpd_conn_t * conn, const char *msg); + +/** + * + * Send a minimalistic HTML error document with HTTP status 501. + * + * @see HTTP_STATUS_501_REASON_PHRASE + * + */ +extern herror_t httpd_send_not_implemented(httpd_conn_t *conn, const char *msg); #ifdef __cplusplus } |