diff options
-rw-r--r-- | examples/nanohttp/http_server.c | 10 | ||||
-rw-r--r-- | examples/nanohttp/httpget.c | 74 | ||||
-rw-r--r-- | libcsoap/soap-addressing.h | 24 | ||||
-rw-r--r-- | libcsoap/soap-admin.c | 6 | ||||
-rw-r--r-- | libcsoap/soap-nhttp.c | 6 | ||||
-rw-r--r-- | libcsoap/soap-wsil.c | 6 | ||||
-rw-r--r-- | nanohttp/nanohttp-admin.c | 6 | ||||
-rw-r--r-- | nanohttp/nanohttp-common.h | 81 | ||||
-rw-r--r-- | nanohttp/nanohttp-server.c | 6 |
9 files changed, 120 insertions, 99 deletions
diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c index 655ad7a..0e1659a 100644 --- a/examples/nanohttp/http_server.c +++ b/examples/nanohttp/http_server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_server.c,v 1.8 2006/11/25 15:06:57 m0gg Exp $ +* $Id: http_server.c,v 1.9 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -55,7 +55,7 @@ static int simple_authenticator(struct hrequest_t *req, const char *user, const static void secure_service(httpd_conn_t *conn, struct hrequest_t *req) { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" @@ -72,7 +72,7 @@ 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, "Not found"); + httpd_send_header(conn, 404, HTTP_STATUS_404_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" @@ -96,7 +96,7 @@ static void headers_service(httpd_conn_t *conn, struct hrequest_t *req) { hpair_t *walker; - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" @@ -125,7 +125,7 @@ static void headers_service(httpd_conn_t *conn, struct hrequest_t *req) static void root_service(httpd_conn_t *conn, struct hrequest_t *req) { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" diff --git a/examples/nanohttp/httpget.c b/examples/nanohttp/httpget.c deleted file mode 100644 index e70469d..0000000 --- a/examples/nanohttp/httpget.c +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************** -* $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 -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Library General Public -* License as published by the Free Software Foundation; either -* version 2 of the License, or (at your option) any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Library General Public License for more details. -* -* You should have received a copy of the GNU Library General Public -* License along with this library; if not, write to the -* Free Software Foundation, Inc., 59 Temple Place - Suite 330, -* Boston, MA 02111-1307, USA. -* -* Email: ayaz@jprogrammer.net -******************************************************************/ -#include <nanohttp/nanohttp-client.h> - -#include <stdio.h> - - -int main(int argc, char *argv[]) -{ - httpc_conn_t *conn; - hresponse_t *res; - hpair_t *pair; - - if (argc < 2) { - fprintf(stderr, "usage %s <url>\n", argv[0]); - exit(1); - } - - 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]); - - if (res != NULL) { - log_info2("Spec : '%s'", res->spec); - log_info2("Status: %d", res->errcode); - log_info2("Desc : '%s'", res->desc); - - if (res->body) { - pair = res->header; - while (pair != NULL) { - log_debug3("%s: %s", pair->key, pair->value); - pair = pair->next; - } - - puts(res->body); - } - else - log_error1("body is null"); - - hresponse_free(res); - } else { - log_error1("response object is null"); - } - - httpc_free(conn); - return 0; -} diff --git a/libcsoap/soap-addressing.h b/libcsoap/soap-addressing.h index 0893ac5..ed2ca86 100644 --- a/libcsoap/soap-addressing.h +++ b/libcsoap/soap-addressing.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: soap-addressing.h,v 1.4 2006/11/24 10:54:03 m0gg Exp $ + * $Id: soap-addressing.h,v 1.5 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2006 Heiko Ronsdorf @@ -24,7 +24,7 @@ #ifndef __csoap_addressing_h #define __csoap_addressing_h -/** +/** @file * * WS-Addressing provides transport-neutral mechanisms to address Web services * and messages. Specifically, this specification defines XML [XML 1.0, XML @@ -35,11 +35,27 @@ * in a transport-neutral manner. * * @author H. Ronsdorf - * @version $Revision: 1.4 $ - * @see http://www.w3.org/TR/ws-addr-core/ + * @version $Revision: 1.5 $ + * + * @see http://www.w3.org/TR/ws-addr-core/, + * http://www.w3.org/TR/REC-xml-names/ + * + */ + +/** + * + * Namespace used for the addressing elements. * */ #define WSA_NAMESPACE "http://www.w3.org/2005/08/addressing" + +/** + * + * Prefix for the WSA namespace used internally. + * + * @see WSA_NAMESPACE + * + */ #define WSA_NAMESPACE_PREFIX "wsa" /** diff --git a/libcsoap/soap-admin.c b/libcsoap/soap-admin.c index 20b3412..81310ed 100644 --- a/libcsoap/soap-admin.c +++ b/libcsoap/soap-admin.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-admin.c,v 1.8 2006/11/25 15:06:57 m0gg Exp $ +* $Id: soap-admin.c,v 1.9 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -60,7 +60,7 @@ static void _soap_admin_send_title(httpd_conn_t *conn, const char *title) { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html><head><style>"); http_output_stream_write_string(conn->out, @@ -179,7 +179,7 @@ _soap_admin_entry(httpd_conn_t * conn, struct hrequest_t * req) } else { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" diff --git a/libcsoap/soap-nhttp.c b/libcsoap/soap-nhttp.c index 0546c58..ce48394 100644 --- a/libcsoap/soap-nhttp.c +++ b/libcsoap/soap-nhttp.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-nhttp.c,v 1.3 2006/11/25 15:06:57 m0gg Exp $ +* $Id: soap-nhttp.c,v 1.4 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -75,7 +75,7 @@ _soap_nhttp_send_document(httpd_conn_t *conn, xmlDocPtr doc) sprintf(length, "%d", xmlBufferLength(buf)); httpd_set_header(conn, HEADER_CONTENT_TYPE, "text/xml"); httpd_set_header(conn, HEADER_CONTENT_LENGTH, length); - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, xmlBufferContent(buf)); @@ -157,7 +157,7 @@ soap_nhttp_process(httpd_conn_t * conn, struct hrequest_t * req) if (req->method != HTTP_REQUEST_POST) { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" diff --git a/libcsoap/soap-wsil.c b/libcsoap/soap-wsil.c index 2a11130..f4960ef 100644 --- a/libcsoap/soap-wsil.c +++ b/libcsoap/soap-wsil.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: soap-wsil.c,v 1.3 2006/11/25 15:06:58 m0gg Exp $ +* $Id: soap-wsil.c,v 1.4 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -84,7 +84,7 @@ static void _soap_wsil_handle_get(httpd_conn_t * conn, struct hrequest_t * req) { httpd_set_header(conn, HEADER_CONTENT_TYPE, "text/xml"); - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>" @@ -108,7 +108,7 @@ _soap_wsil_entry(httpd_conn_t * conn, struct hrequest_t * req) } else { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" diff --git a/nanohttp/nanohttp-admin.c b/nanohttp/nanohttp-admin.c index fa2fdaf..d5d5939 100644 --- a/nanohttp/nanohttp-admin.c +++ b/nanohttp/nanohttp-admin.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-admin.c,v 1.5 2006/11/25 15:06:58 m0gg Exp $ +* $Id: nanohttp-admin.c,v 1.6 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A SOAP client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -48,7 +48,7 @@ static void _httpd_admin_send_title(httpd_conn_t *conn, const char *title) { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html><head><style>"); http_output_stream_write_string(conn->out, @@ -165,7 +165,7 @@ _httpd_admin_entry(httpd_conn_t * conn, struct hrequest_t *req) } else { - httpd_send_header(conn, 200, "OK"); + httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE); http_output_stream_write_string(conn->out, "<html>" "<head>" diff --git a/nanohttp/nanohttp-common.h b/nanohttp/nanohttp-common.h index 324f3db..272ff91 100644 --- a/nanohttp/nanohttp-common.h +++ b/nanohttp/nanohttp-common.h @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: nanohttp-common.h,v 1.35 2006/11/25 15:38:10 m0gg Exp $ + * $Id: nanohttp-common.h,v 1.36 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003-2004 Ferhat Ayaz @@ -422,6 +422,85 @@ typedef enum _hreq_method /** * + * The Status-Code element is a 3-digit integer result code of the attempt to + * understand and satisfy the request. These codes are fully defined in section + * 10. The Reason-Phrase is intended to give a short textual description of the + * Status-Code. The Status-Code is intended for use by automata and the + * Reason-Phrase is intended for the human user. The client is not required to + * examine or display the Reason- Phrase. The first digit of the Status-Code + * defines the class of response. The last two digits do not have any + * categorization role. There are 5 values for the first digit: + * + * - 1xx: Informational - Request received, continuing process + * - 2xx: Success - The action was successfully received, understood, and + * accepted + * - 3xx: Redirection - Further action must be taken in order to complete the + * request + * - 4xx: Client Error - The request contains bad syntax or cannot be fulfilled + * - 5xx: Server Error - The server failed to fulfill an apparently valid request + * + * The individual values of the numeric status codes defined for HTTP/1.1, and an + * example set of corresponding Reason-Phrase's, are presented below. The reason + * phrases listed here are only recommendations -- they MAY be replaced by local + * equivalents without affecting the protocol. + * + * HTTP status codes are extensible. HTTP applications are not required to + * understand the meaning of all registered status codes, though such + * understanding is obviously desirable. However, applications MUST understand + * the class of any status code, as indicated by the first digit, and treat any + * unrecognized response as being equivalent to the x00 status code of that class, + * with the exception that an unrecognized response MUST NOT be cached. For + * example, if an unrecognized status code of 431 is received by the client, it + * can safely assume that there was something wrong with its request and treat + * the response as if it had received a 400 status code. In such cases, user + * agents SHOULD present to the user the entity returned with the response, + * since that entity is likely to include human-readable information which will + * explain the unusual status. + * + */ +#define HTTP_STATUS_100_REASON_PHRASE "Continue" +#define HTTP_STATUS_101_REASON_PHRASE "Switching Protocols" +#define HTTP_STATUS_200_REASON_PHRASE "OK" +#define HTTP_STATUS_201_REASON_PHRASE "Created" +#define HTTP_STATUS_202_REASON_PHRASE "Accepted" +#define HTTP_STATUS_203_REASON_PHRASE "Non-Authoritative Information" +#define HTTP_STATUS_204_REASON_PHRASE "No Content" +#define HTTP_STATUS_205_REASON_PHRASE "Reset Content" +#define HTTP_STATUS_206_REASON_PHRASE "Partial Content" +#define HTTP_STATUS_300_REASON_PHRASE "Multiple Choices" +#define HTTP_STATUS_301_REASON_PHRASE "Moved Permanently" +#define HTTP_STATUS_302_REASON_PHRASE "Found" +#define HTTP_STATUS_303_REASON_PHRASE "See Other" +#define HTTP_STATUS_304_REASON_PHRASE "Not Modified" +#define HTTP_STATUS_305_REASON_PHRASE "Use Proxy" +#define HTTP_STATUS_307_REASON_PHRASE "Temporary Redirect" +#define HTTP_STATUS_400_REASON_PHRASE "Bad Request" +#define HTTP_STATUS_401_REASON_PHRASE "Unauthorized" +#define HTTP_STATUS_402_REASON_PHRASE "Payment Required" +#define HTTP_STATUS_403_REASON_PHRASE "Forbidden" +#define HTTP_STATUS_404_REASON_PHRASE "Not Found" +#define HTTP_STATUS_405_REASON_PHRASE "Method Not Allowed" +#define HTTP_STATUS_406_REASON_PHRASE "Not Acceptable" +#define HTTP_STATUS_407_REASON_PHRASE "Proxy Authentication Required" +#define HTTP_STATUS_408_REASON_PHRASE "Request Time-out" +#define HTTP_STATUS_409_REASON_PHRASE "Conflict" +#define HTTP_STATUS_410_REASON_PHRASE "Gone" +#define HTTP_STATUS_411_REASON_PHRASE "Length Required" +#define HTTP_STATUS_412_REASON_PHRASE "Precondition Failed" +#define HTTP_STATUS_413_REASON_PHRASE "Request Entity Too Large" +#define HTTP_STATUS_414_REASON_PHRASE "Request-URI Too Large" +#define HTTP_STATUS_415_REASON_PHRASE "Unsupported Media Type" +#define HTTP_STATUS_416_REASON_PHRASE "Requested range not satisfiable" +#define HTTP_STATUS_417_REASON_PHRASE "Expectation Failed" +#define HTTP_STATUS_500_REASON_PHRASE "Internal Server Error" +#define HTTP_STATUS_501_REASON_PHRASE "Not Implemented" +#define HTTP_STATUS_502_REASON_PHRASE "Bad Gateway" +#define HTTP_STATUS_503_REASON_PHRASE "Service Unavailable" +#define HTTP_STATUS_504_REASON_PHRASE "Gateway Time-out" +#define HTTP_STATUS_505_REASON_PHRASE "HTTP Version not supported" + +/** + * * hpairnode_t represents a pair (key, value) pair. This is also a linked list. * */ diff --git a/nanohttp/nanohttp-server.c b/nanohttp/nanohttp-server.c index e79e448..c144acf 100644 --- a/nanohttp/nanohttp-server.c +++ b/nanohttp/nanohttp-server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-server.c,v 1.67 2006/11/25 15:06:58 m0gg Exp $ +* $Id: nanohttp-server.c,v 1.68 2006/11/25 16:35:57 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -466,7 +466,7 @@ httpd_send_internal_error(httpd_conn_t * conn, const char *errmsg) snprintf(buflen, 5, "%d", strlen(buffer)); httpd_set_header(conn, HEADER_CONTENT_LENGTH, buflen); - httpd_send_header(conn, 500, "INTERNAL"); + httpd_send_header(conn, 500, HTTP_STATUS_500_REASON_PHRASE); return http_output_stream_write_string(conn->out, buffer); } @@ -719,7 +719,7 @@ httpd_session_main(void *data) httpd_set_header(rconn, HEADER_WWW_AUTHENTICATE, "Basic realm=\"nanoHTTP\""); - httpd_send_header(rconn, 401, "Unauthorized"); + httpd_send_header(rconn, 401, HTTP_STATUS_401_REASON_PHRASE); http_output_stream_write_string(rconn->out, template); done = 1; } |