http_status.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2005 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. /**@CFILE http_status.c HTTP status codes.
  25. *
  26. * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  27. *
  28. * @date Created: Tue Sep 18 18:58:21 2001 ppessi
  29. */
  30. #include "config.h"
  31. #include <stddef.h>
  32. #include <sofia-sip/http_status.h>
  33. char const
  34. http_100_continue[] = "Continue",
  35. http_101_switching[] = "Switching Protocols",
  36. http_200_ok[] = "OK",
  37. http_201_created[] = "Created",
  38. http_202_accepted[] = "Accepted",
  39. http_203_non_auth_info[] = "Non-Authoritative Information",
  40. http_204_no_content[] = "No Content",
  41. http_205_reset_content[] = "Reset Content",
  42. http_206_partial_content[] = "Partial Content",
  43. http_300_multiple_choices[] = "Multiple Choices",
  44. http_301_moved_permanently[] = "Moved Permanently",
  45. http_302_found[] = "Found",
  46. http_303_see_other[] = "See Other",
  47. http_304_not_modified[] = "Not Modified",
  48. http_305_use_proxy[] = "Use Proxy",
  49. http_307_temporary_redirect[] = "Temporary Redirect",
  50. http_400_bad_request[] = "Bad Request",
  51. http_401_unauthorized[] = "Unauthorized",
  52. http_402_payment_required[] = "Payment Required",
  53. http_403_forbidden[] = "Forbidden",
  54. http_404_not_found[] = "Not Found",
  55. http_405_not_allowed[] = "Method Not Allowed",
  56. http_406_not_acceptable[] = "Not Acceptable",
  57. http_407_proxy_auth[] = "Proxy Authentication Required",
  58. http_408_timeout[] = "Request Timeout",
  59. http_409_conflict[] = "Conflict",
  60. http_410_gone[] = "Gone",
  61. http_411_no_length[] = "Length Required",
  62. http_412_precondition[] = "Precondition Failed",
  63. http_413_entity_too_large[] = "Request Entity Too Large",
  64. http_414_uri_too_long[] = "Request-URI Too Long",
  65. http_415_media_type[] = "Unsupported Media Type",
  66. http_416_requested_range[] = "Requested Range Not Satisfiable",
  67. http_417_expectation[] = "Expectation Failed",
  68. http_426_upgrade[] = "Upgrade Required",
  69. http_500_internal_server[] = "Internal Server Error",
  70. http_501_not_implemented[] = "Not Implemented",
  71. http_502_bad_gateway[] = "Bad Gateway",
  72. http_503_no_service[] = "Service Unavailable",
  73. http_504_gateway_timeout[] = "Gateway Timeout",
  74. http_505_http_version[] = "HTTP Version Not Supported";
  75. char const *http_status_phrase(int status)
  76. {
  77. if (status < 100 || status > 699)
  78. return NULL;
  79. switch (status) {
  80. case 100: return http_100_continue;
  81. case 101: return http_101_switching;
  82. case 200: return http_200_ok;
  83. case 201: return http_201_created;
  84. case 202: return http_202_accepted;
  85. case 203: return http_203_non_auth_info;
  86. case 204: return http_204_no_content;
  87. case 205: return http_205_reset_content;
  88. case 206: return http_206_partial_content;
  89. case 300: return http_300_multiple_choices;
  90. case 301: return http_301_moved_permanently;
  91. case 302: return http_302_found;
  92. case 303: return http_303_see_other;
  93. case 304: return http_304_not_modified;
  94. case 305: return http_305_use_proxy;
  95. case 307: return http_307_temporary_redirect;
  96. case 400: return http_400_bad_request;
  97. case 401: return http_401_unauthorized;
  98. case 402: return http_402_payment_required;
  99. case 403: return http_403_forbidden;
  100. case 404: return http_404_not_found;
  101. case 405: return http_405_not_allowed;
  102. case 406: return http_406_not_acceptable;
  103. case 407: return http_407_proxy_auth;
  104. case 408: return http_408_timeout;
  105. case 409: return http_409_conflict;
  106. case 410: return http_410_gone;
  107. case 411: return http_411_no_length;
  108. case 412: return http_412_precondition;
  109. case 413: return http_413_entity_too_large;
  110. case 414: return http_414_uri_too_long;
  111. case 415: return http_415_media_type;
  112. case 416: return http_416_requested_range;
  113. case 417: return http_417_expectation;
  114. case 426: return http_426_upgrade;
  115. case 500: return http_500_internal_server;
  116. case 501: return http_501_not_implemented;
  117. case 502: return http_502_bad_gateway;
  118. case 503: return http_503_no_service;
  119. case 504: return http_504_gateway_timeout;
  120. case 505: return http_505_http_version;
  121. }
  122. return " ";
  123. }