status.go 774 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2011 Andy Balholm. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // ICAP status codes.
  5. package icap
  6. import (
  7. "net/http"
  8. )
  9. var statusText = map[int]string{
  10. 100: "Continue",
  11. 204: "No Modifications",
  12. 400: "Bad Request",
  13. 404: "ICAP Service Not Found",
  14. 405: "Method Not Allowed",
  15. 408: "Request Timeout",
  16. 500: "Server Error",
  17. 501: "Method Not Implemented",
  18. 502: "Bad Gateway",
  19. 503: "Service Overloaded",
  20. 505: "ICAP Version Not Supported",
  21. }
  22. // StatusText returns a text for the ICAP status code. It returns the empty string if the code is unknown.
  23. func StatusText(code int) string {
  24. text, ok := statusText[code]
  25. if ok {
  26. return text
  27. }
  28. return http.StatusText(code)
  29. }