http_message_constants.cc revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
14e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
24e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
34e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// found in the LICENSE file.
44e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
54e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "net/tools/balsa/http_message_constants.h"
64e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
74e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)namespace net {
84e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
94e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)const char* get_http_status_message(int status_message) {
104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  switch (status_message) {
114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 100:
124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Continue";
134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 101:
144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Switching Protocols";
154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 200:
164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "OK";
174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 201:
184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Created";
194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 202:
204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Accepted";
214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 203:
224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Non-Authoritative Information";
234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 204:
244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "No Content";
254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 205:
264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Reset Content";
274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 206:
284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Partial Content";
294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 300:
304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Multiple Choices";
314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 301:
324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Moved Permanently";
334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 302:
344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Found";
354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 303:
364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "See Other";
374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 304:
384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Not Modified";
394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 305:
404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Use Proxy";
414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 307:
424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Temporary Redirect";
434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 400:
444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Bad Request";
454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 401:
464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Unauthorized";
474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 402:
484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Payment Required";
494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 403:
504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Forbidden";
514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 404:
524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Not Found";
534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 405:
544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Method Not Allowed";
554e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 406:
564e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Not Acceptable";
574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 407:
584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Proxy Authentication Required";
594e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 408:
604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Request Time-out";
614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 409:
624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Conflict";
634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 410:
644e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Gone";
654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 411:
664e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Length Required";
674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 412:
684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Precondition Failed";
694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 413:
704e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Request Entity Too Large";
714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 414:
724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Request-URI Too Large";
734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 415:
744e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Unsupported Media Type";
754e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 416:
764e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Requested range not satisfiable";
774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 417:
784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Expectation Failed";
794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 500:
804e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Internal Server Error";
814e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 501:
824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Not Implemented";
834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 502:
844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Bad Gateway";
854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 503:
864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Service Unavailable";
874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 504:
884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "Gateway Time-out";
894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    case 505:
904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)      return "HTTP Version not supported";
914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  }
924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  return "unknown";
934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)}
944e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)////////////////////////////////////////////////////////////////////////////////
964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)const int http_status_codes[] = {
984e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  100,
994e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  101,
1004e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  200,
1014e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  201,
1024e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  202,
1034e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  203,
1044e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  204,
1054e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  205,
1064e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  206,
1074e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  300,
1084e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  301,
1094e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  302,
1104e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  303,
1114e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  304,
1124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  305,
1134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  307,
1144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  400,
1154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  401,
1164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  402,
1174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  403,
1184e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  404,
1194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  405,
1204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  406,
1214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  407,
1224e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  408,
1234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  409,
1244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  410,
1254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  411,
1264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  412,
1274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  413,
1284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  414,
1294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  415,
1304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  416,
1314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  417,
1324e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  500,
1334e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  501,
1344e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  502,
1354e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  503,
1364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  504,
1374e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  505
1384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)};
1394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1404e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)////////////////////////////////////////////////////////////////////////////////
1414e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1424e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)const int http_status_code_count = sizeof(http_status_codes) /
1434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                                   sizeof(http_status_codes[0]);
1444e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
1454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)}  // namespace net
1464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
147