Hi All !
We use the Kannel for our project and we made some little modifications on it.
I am going to send these patches back to the community.
The first one is a very simply modification, it changes the constant 'foo'
word to real reason phrases
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html) in the status-line of
the HTTP response.
Index: gateway/gwlib/http.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/http.c,v
retrieving revision 1.217
diff -r1.217 http.c
2350c2350
< response = octstr_format("HTTP/1.0 %d Foo\r\n", status);
---
> response = octstr_format("HTTP/1.0 %d %s\r\n", status,
http_reason_phrase(status));
2352c2352
< response = octstr_format("HTTP/1.1 %d Foo\r\n", status);
---
> response = octstr_format("HTTP/1.1 %d %s\r\n", status,
http_reason_phrase(status));
3282a3283,3380
> static char *http_error_messages[] = {
> "OK", /* 200 */
> "Created", /* 201 */
> "Accepted", /* 202 */
> "No Content", /* 204 */
> "Reset Content", /* 205 */
> "Moved Permanently", /* 301 */
> "Found", /* 302 */
> "See Other", /* 303 */
> "Not Modified", /* 304 */
> "Temporary Redirect", /* 307 */
> "Bad Request", /* 400 */
> "Unauthorized", /* 401 */
> "Forbidden", /* 403 */
> "Not Found", /* 404 */
> "Method Not Allowed", /* 405 */
> "Not Acceptable", /* 406 */
> "Request Entity Too Large", /* 413 */
> "Unsupported Media Type", /* 415 */
> "Internal Server Error", /* 500 */
> "Not Implemented", /* 501 */
> "Bad Gateway" /* 502 */
> };
>
> /*
> * The http_send_reply(...) uses this function to determinate the
> * reason pahrase for a status code.
> */
> char *http_reason_phrase(int status)
> {
> char *result=0;
> switch (status) {
> case HTTP_OK:
> result= http_error_messages[0];
> break;
> case HTTP_CREATED:
> result= http_error_messages[1];
> break;
> case HTTP_ACCEPTED:
> result= http_error_messages[2];
> break;
> case HTTP_NO_CONTENT:
> result= http_error_messages[3];
> break;
> case HTTP_RESET_CONTENT:
> result= http_error_messages[4];
> break;
> case HTTP_MOVED_PERMANENTLY:
> result= http_error_messages[5];
> break;
> case HTTP_FOUND:
> result= http_error_messages[6];
> break;
> case HTTP_SEE_OTHER:
> result= http_error_messages[7];
> break;
> case HTTP_NOT_MODIFIED:
> result= http_error_messages[8];
> break;
> case HTTP_TEMPORARY_REDIRECT:
> result= http_error_messages[9];
> break;
> case HTTP_BAD_REQUEST:
> result= http_error_messages[10];
> break;
> case HTTP_UNAUTHORIZED:
> result= http_error_messages[11];
> break;
> case HTTP_FORBIDDEN:
> result= http_error_messages[12];
> break;
> case HTTP_NOT_FOUND:
> result= http_error_messages[13];
> break;
> case HTTP_BAD_METHOD:
> result= http_error_messages[14];
> break;
> case HTTP_NOT_ACCEPTABLE:
> result= http_error_messages[15];
> break;
> case HTTP_REQUEST_ENTITY_TOO_LARGE:
> result= http_error_messages[16];
> break;
> case HTTP_UNSUPPORTED_MEDIA_TYPE:
> result= http_error_messages[17];
> break;
> case HTTP_INTERNAL_SERVER_ERROR:
> result= http_error_messages[18];
> break;
> case HTTP_NOT_IMPLEMENTED:
> result= http_error_messages[19];
> break;
> case HTTP_BAD_GATEWAY:
> result= http_error_messages[20];
> break;
> }
> return result;
> }
Dod
--
Zoltan Dudas
Software Engineer
SEI Magyarorszag Kft.
WEB: http://www.sei-it.com
E-Mail: [EMAIL PROTECTED]
Phone: +36 52 889 532
Fax: +36 52 889 599
Index: gateway/gwlib/http.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/http.c,v
retrieving revision 1.217
diff -r1.217 http.c
2350c2350
< response = octstr_format("HTTP/1.0 %d Foo\r\n", status);
---
> response = octstr_format("HTTP/1.0 %d %s\r\n", status, http_reason_phrase(status));
2352c2352
< response = octstr_format("HTTP/1.1 %d Foo\r\n", status);
---
> response = octstr_format("HTTP/1.1 %d %s\r\n", status, http_reason_phrase(status));
3282a3283,3380
> static char *http_error_messages[] = {
> "OK", /* 200 */
> "Created", /* 201 */
> "Accepted", /* 202 */
> "No Content", /* 204 */
> "Reset Content", /* 205 */
> "Moved Permanently", /* 301 */
> "Found", /* 302 */
> "See Other", /* 303 */
> "Not Modified", /* 304 */
> "Temporary Redirect", /* 307 */
> "Bad Request", /* 400 */
> "Unauthorized", /* 401 */
> "Forbidden", /* 403 */
> "Not Found", /* 404 */
> "Method Not Allowed", /* 405 */
> "Not Acceptable", /* 406 */
> "Request Entity Too Large", /* 413 */
> "Unsupported Media Type", /* 415 */
> "Internal Server Error", /* 500 */
> "Not Implemented", /* 501 */
> "Bad Gateway" /* 502 */
> };
>
> /*
> * The http_send_reply(...) uses this function to determinate the
> * reason pahrase for a status code.
> */
> char *http_reason_phrase(int status)
> {
> char *result=0;
> switch (status) {
> case HTTP_OK:
> result= http_error_messages[0];
> break;
> case HTTP_CREATED:
> result= http_error_messages[1];
> break;
> case HTTP_ACCEPTED:
> result= http_error_messages[2];
> break;
> case HTTP_NO_CONTENT:
> result= http_error_messages[3];
> break;
> case HTTP_RESET_CONTENT:
> result= http_error_messages[4];
> break;
> case HTTP_MOVED_PERMANENTLY:
> result= http_error_messages[5];
> break;
> case HTTP_FOUND:
> result= http_error_messages[6];
> break;
> case HTTP_SEE_OTHER:
> result= http_error_messages[7];
> break;
> case HTTP_NOT_MODIFIED:
> result= http_error_messages[8];
> break;
> case HTTP_TEMPORARY_REDIRECT:
> result= http_error_messages[9];
> break;
> case HTTP_BAD_REQUEST:
> result= http_error_messages[10];
> break;
> case HTTP_UNAUTHORIZED:
> result= http_error_messages[11];
> break;
> case HTTP_FORBIDDEN:
> result= http_error_messages[12];
> break;
> case HTTP_NOT_FOUND:
> result= http_error_messages[13];
> break;
> case HTTP_BAD_METHOD:
> result= http_error_messages[14];
> break;
> case HTTP_NOT_ACCEPTABLE:
> result= http_error_messages[15];
> break;
> case HTTP_REQUEST_ENTITY_TOO_LARGE:
> result= http_error_messages[16];
> break;
> case HTTP_UNSUPPORTED_MEDIA_TYPE:
> result= http_error_messages[17];
> break;
> case HTTP_INTERNAL_SERVER_ERROR:
> result= http_error_messages[18];
> break;
> case HTTP_NOT_IMPLEMENTED:
> result= http_error_messages[19];
> break;
> case HTTP_BAD_GATEWAY:
> result= http_error_messages[20];
> break;
> }
> return result;
> }