1
0

reasons.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * Copyright 2015 Paul Querna
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package cacheobject
  18. // Repersents a potential Reason to not cache an object.
  19. //
  20. // Applications may wish to ignore specific reasons, which will make them non-RFC
  21. // compliant, but this type gives them specific cases they can choose to ignore,
  22. // making them compliant in as many cases as they can.
  23. type Reason int
  24. const (
  25. // The request method was POST and an Expiration header was not supplied.
  26. ReasonRequestMethodPOST Reason = iota
  27. // The request method was PUT and PUTs are not cachable.
  28. ReasonRequestMethodPUT
  29. // The request method was DELETE and DELETEs are not cachable.
  30. ReasonRequestMethodDELETE
  31. // The request method was CONNECT and CONNECTs are not cachable.
  32. ReasonRequestMethodCONNECT
  33. // The request method was OPTIONS and OPTIONS are not cachable.
  34. ReasonRequestMethodOPTIONS
  35. // The request method was TRACE and TRACEs are not cachable.
  36. ReasonRequestMethodTRACE
  37. // The request method was not recognized by cachecontrol, and should not be cached.
  38. ReasonRequestMethodUnkown
  39. // The request included an Cache-Control: no-store header
  40. ReasonRequestNoStore
  41. // The request included an Authorization header without an explicit Public or Expiration time: http://tools.ietf.org/html/rfc7234#section-3.2
  42. ReasonRequestAuthorizationHeader
  43. // The response included an Cache-Control: no-store header
  44. ReasonResponseNoStore
  45. // The response included an Cache-Control: private header and this is not a Private cache
  46. ReasonResponsePrivate
  47. // The response failed to meet at least one of the conditions specified in RFC 7234 section 3: http://tools.ietf.org/html/rfc7234#section-3
  48. ReasonResponseUncachableByDefault
  49. )
  50. func (r Reason) String() string {
  51. switch r {
  52. case ReasonRequestMethodPOST:
  53. return "ReasonRequestMethodPOST"
  54. case ReasonRequestMethodPUT:
  55. return "ReasonRequestMethodPUT"
  56. case ReasonRequestMethodDELETE:
  57. return "ReasonRequestMethodDELETE"
  58. case ReasonRequestMethodCONNECT:
  59. return "ReasonRequestMethodCONNECT"
  60. case ReasonRequestMethodOPTIONS:
  61. return "ReasonRequestMethodOPTIONS"
  62. case ReasonRequestMethodTRACE:
  63. return "ReasonRequestMethodTRACE"
  64. case ReasonRequestMethodUnkown:
  65. return "ReasonRequestMethodUnkown"
  66. case ReasonRequestNoStore:
  67. return "ReasonRequestNoStore"
  68. case ReasonRequestAuthorizationHeader:
  69. return "ReasonRequestAuthorizationHeader"
  70. case ReasonResponseNoStore:
  71. return "ReasonResponseNoStore"
  72. case ReasonResponsePrivate:
  73. return "ReasonResponsePrivate"
  74. case ReasonResponseUncachableByDefault:
  75. return "ReasonResponseUncachableByDefault"
  76. }
  77. panic(r)
  78. }