3 * Copyright 2007 Google Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 * Http Response Code Constants.
22 namespace google\appengine\ext\cloud_storage_streams
;
25 * Declares well known HTTP response codes and associated error messages.
27 final class HttpResponse
{
30 const NO_CONTENT
= 204;
31 const PARTIAL_CONTENT
= 206;
33 const RESUME_INCOMPLETE
= 308;
35 const FORBIDDEN
= 403;
36 const NOT_FOUND
= 404;
37 const REQUEST_TIMEOUT
= 408;
38 const PRECONDITION_FAILED
= 412;
39 const RANGE_NOT_SATISFIABLE
= 416;
41 const INTERNAL_SERVER_ERROR
= 500;
42 const BAD_GATEWAY
= 502;
43 const SERVICE_UNAVAILABLE
= 503;
44 const GATEWAY_TIMEOUT
= 504;
46 private static $status_messages = [
48 self
::CREATED
=> "CREATE",
49 self
::NO_CONTENT
=> "NO CONTENT",
50 self
::PARTIAL_CONTENT
=> "PARTIAL CONTENT",
51 self
::RESUME_INCOMPLETE
=> "RESUME INCOMPLETE",
52 self
::FORBIDDEN
=> "FORBIDDEN",
53 self
::NOT_FOUND
=> "NOT FOUND",
54 self
::REQUEST_TIMEOUT
=> "REQUEST TIMEOUT",
55 self
::PRECONDITION_FAILED
=> "PRECONDITION FAILED",
56 self
::RANGE_NOT_SATISFIABLE
=> "RANGE NOT SATISFIABLE",
57 self
::INTERNAL_SERVER_ERROR
=> "INTERNAL SERVER ERROR",
60 public static function getStatusMessage($code) {
61 if (array_key_exists($code, self
::$status_messages)) {
62 return self
::$status_messages[$code];
64 return sprintf("Unknown Code %d", $code);