Re: [PATCH] Reason pharses into the HTTP response
Alexander Malysh <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | Centrium GmbH |
| Message-ID | <[email protected]> |
Hi again, patch commited to cvs. Thanks a lot! On Thursday 03 June 2004 15:05, Zoltán Dudás wrote: > Hi All, > > There is the most newer version. If everybody agrees with it, I will send > it to the [email protected]. :) > > Dod > > > Index: gateway/gwlib/http.c > =================================================================== > RCS file: /home/cvs/gateway/gwlib/http.c,v > retrieving revision 1.217 > diff -u -r1.217 http.c > --- gateway/gwlib/http.c 16 Feb 2004 19:41:26 -0000 1.217 > +++ gateway/gwlib/http.c 3 Jun 2004 13:01:04 -0000 > @@ -2338,6 +2338,59 @@ > return client; > } > > +/* > + * The http_send_reply(...) uses this function to determinate the > + * reason pahrase for a status code. > + */ > +const char *http_reason_phrase(int status) > +{ > + switch (status) { > + case HTTP_OK: > + return "OK"; /* 200 */ > + case HTTP_CREATED: > + return "Created"; /* 201 */ > + case HTTP_ACCEPTED: > + return "Accepted"; /* 202 */ > + case HTTP_NO_CONTENT: > + return "No Content"; /* 204 */ > + case HTTP_RESET_CONTENT: > + return "Reset Content"; /* 205 */ > + case HTTP_MOVED_PERMANENTLY: > + return "Moved Permanently"; /* 301 */ > + case HTTP_FOUND: > + return "Found"; /* 302 */ > + case HTTP_SEE_OTHER: > + return "See Other"; /* 303 */ > + case HTTP_NOT_MODIFIED: > + return "Not Modified"; /* 304 */ > + case HTTP_TEMPORARY_REDIRECT: > + return "Temporary Redirect"; /* 307 */ > + case HTTP_BAD_REQUEST: > + return "Bad Request"; /* 400 */ > + case HTTP_UNAUTHORIZED: > + return "Unauthorized"; /* 401 */ > + case HTTP_FORBIDDEN: > + return "Forbidden"; /* 403 */ > + case HTTP_NOT_FOUND: > + return "Not Found"; /* 404 */ > + case HTTP_BAD_METHOD: > + return "Method Not Allowed"; /* 405 */ > + case HTTP_NOT_ACCEPTABLE: > + return "Not Acceptable"; /* 406 */ > + case HTTP_REQUEST_ENTITY_TOO_LARGE: > + return "Request Entity Too Large"; /* 413 */ > + case HTTP_UNSUPPORTED_MEDIA_TYPE: > + return "Unsupported Media Type"; /* 415 */ > + case HTTP_INTERNAL_SERVER_ERROR: > + return "Internal Server Error"; /* 500 */ > + case HTTP_NOT_IMPLEMENTED: > + return "Not Implemented"; /* 501 */ > + case HTTP_BAD_GATEWAY: > + return "Bad Gateway"; /* 502 */ > + } > + return "Foo"; > +} > + > > void http_send_reply(HTTPClient *client, int status, List *headers, > Octstr *body) > @@ -2347,9 +2400,9 @@ > int ret; > > if (client->use_version_1_0) > - 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)); > else > - 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)); > > /* identify ourselfs */ > octstr_format_append(response, "Server: " GW_NAME "/%s\r\n", > GW_VERSION); -- Best regards / Mit besten Grüßen aus Düsseldorf Dipl.-Ing. Alexander Malysh ___________________________________________ Centrium GmbH Vogelsanger Weg 80 40470 Düsseldorf Fon: +49 (0211) 74 84 51 80 Fax: +49 (0211) 277 49 109 email: [email protected] web: www.centrium.de msn: [email protected] icq: 98063111 ___________________________________________ Please avoid sending me Word, Excel or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html