/android/sdk/src/main/java/org/apache/weex/http/Status.java

https://github.com/apache/incubator-weex · Java · 94 lines · 67 code · 6 blank · 21 comment · 1 complexity · 5b91e5fefe216ed2e36a30bff5c0fb4f MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.apache.weex.http;
  20. import java.util.HashMap;
  21. import java.util.Map;
  22. /**
  23. * Created by sospartan on 5/26/16.
  24. */
  25. public class Status {
  26. public static final String UNKNOWN_STATUS = "unknown status";
  27. public static final String ERR_INVALID_REQUEST = "ERR_INVALID_REQUEST";
  28. public static final String ERR_CONNECT_FAILED = "ERR_CONNECT_FAILED";
  29. private static Map<String,String> statusMap = new HashMap<>();
  30. static {
  31. statusMap.put("100","Continue");
  32. statusMap.put("101","Switching Protocol");
  33. statusMap.put("200","OK");
  34. statusMap.put("201","Created");
  35. statusMap.put("202","Accepted");
  36. statusMap.put("203","Non-Authoritative Information");
  37. statusMap.put("204","No Content");
  38. statusMap.put("205","Reset Content");
  39. statusMap.put("206","Partial Content");
  40. statusMap.put("300","Multiple Choice");
  41. statusMap.put("301","Moved Permanently");
  42. statusMap.put("302","Found");
  43. statusMap.put("303","See Other");
  44. statusMap.put("304","Not Modified");
  45. statusMap.put("305","Use Proxy");
  46. statusMap.put("306","unused");
  47. statusMap.put("307","Temporary Redirect");
  48. statusMap.put("308","Permanent Redirect");
  49. statusMap.put("400","Bad Request");
  50. statusMap.put("401","Unauthorized");
  51. statusMap.put("402","Payment Required");
  52. statusMap.put("403","Forbidden");
  53. statusMap.put("404","Not Found");
  54. statusMap.put("405","Method Not Allowed");
  55. statusMap.put("406","Not Acceptable");
  56. statusMap.put("407","Proxy Authentication Required");
  57. statusMap.put("408","Request Timeout");
  58. statusMap.put("409","Conflict");
  59. statusMap.put("410","Gone");
  60. statusMap.put("411","Length Required");
  61. statusMap.put("412","Precondition Failed");
  62. statusMap.put("413","Payload Too Large");
  63. statusMap.put("414","URI Too Long");
  64. statusMap.put("415","Unsupported Media Type");
  65. statusMap.put("416","Requested Range Not Satisfiable");
  66. statusMap.put("417","Expectation Failed");
  67. statusMap.put("418","I'm a teapot");
  68. statusMap.put("421","Misdirected Request");
  69. statusMap.put("426","Upgrade Required");
  70. statusMap.put("428","Precondition Required");
  71. statusMap.put("429","Too Many Requests");
  72. statusMap.put("431","Request Header Fields Too Large");
  73. statusMap.put("500","Internal Server Error");
  74. statusMap.put("501","Not Implemented");
  75. statusMap.put("502","Bad Gateway");
  76. statusMap.put("503","Service Unavailable");
  77. statusMap.put("504","Gateway Timeout");
  78. statusMap.put("505","HTTP Version Not Supported");
  79. statusMap.put("506","Variant Also Negotiates");
  80. statusMap.put("507","Variant Also Negotiates");
  81. statusMap.put("511","Network Authentication Required");
  82. }
  83. public static String getStatusText(String code){
  84. if(!statusMap.containsKey(code))
  85. return UNKNOWN_STATUS;
  86. return statusMap.get(code);
  87. }
  88. }