1 // Copyright 2013 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/http/http_status_code.h" 6 7 #include <ostream> 8 9 #include "base/notreached.h" 10 11 namespace net { 12 GetHttpReasonPhrase(HttpStatusCode code)13const char* GetHttpReasonPhrase(HttpStatusCode code) { 14 if (const char* phrase = TryToGetHttpReasonPhrase(code)) { 15 return phrase; 16 } 17 DUMP_WILL_BE_NOTREACHED_NORETURN() << "unknown HTTP status code " << code; 18 return nullptr; 19 } 20 TryToGetHttpReasonPhrase(HttpStatusCode code)21const char* TryToGetHttpReasonPhrase(HttpStatusCode code) { 22 switch (code) { 23 #define HTTP_STATUS_ENUM_VALUE(label, code, reason) \ 24 case HTTP_##label: \ 25 return reason; 26 #include "net/http/http_status_code_list.h" 27 #undef HTTP_STATUS_ENUM_VALUE 28 29 default: 30 return nullptr; 31 } 32 } 33 34 } // namespace net 35