Skip to content

Commit

Permalink
Merge pull request #26 from k1LoW/get-head
Browse files Browse the repository at this point in the history
Although RFC 9111 does not explicitly define this, in general cacheable methods are GET and HEAD, so the default should be GET and HEAD.
  • Loading branch information
k1LoW authored Dec 14, 2023
2 parents 3b469c2 + 2081669 commit ddcdad8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
15 changes: 8 additions & 7 deletions rfc9111/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package rfc9111
import "net/http"

var defaultUnderstoodMethods = []string{
// Although RFC 9111 does not explicitly define this, in general cacheable methods are GET and HEAD, so the default should be GET and HEAD.
http.MethodGet,
http.MethodHead,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
http.MethodConnect,
http.MethodOptions,
http.MethodTrace,
// http.MethodPost,
// http.MethodPut,
// http.MethodPatch,
// http.MethodDelete,
// http.MethodConnect,
// http.MethodOptions,
// http.MethodTrace,
}

var defaultUnderstoodStatusCodes = []int{
Expand Down
19 changes: 17 additions & 2 deletions rfc9111/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestShared_Storable(t *testing.T) {
time.Time{},
},
{
"GET 500 Cache-Control: public, Last-Modified 2024-12-13 14:15:06 -> +1s",
"GET 200 Cache-Control: public, Last-Modified 2024-12-13 14:15:06 -> +1s",
&http.Request{
Method: http.MethodGet,
},
Expand All @@ -219,7 +219,22 @@ func TestShared_Storable(t *testing.T) {
time.Date(2024, 12, 13, 14, 15, 17, 00, time.UTC),
},
{
"GET 500 Cache-Control: public -> No Store",
"POST 201 Cache-Control: public, Last-Modified 2024-12-13 14:15:06 -> No Store",
&http.Request{
Method: http.MethodPost,
},
&http.Response{
StatusCode: http.StatusCreated,
Header: http.Header{
"Last-Modified": []string{"Mon, 13 Dec 2024 14:15:06 GMT"},
"Cache-Control": []string{"public"},
},
},
false,
time.Time{},
},
{
"GET 200 Cache-Control: public (only) -> No Store",
&http.Request{
Method: http.MethodGet,
},
Expand Down

0 comments on commit ddcdad8

Please sign in to comment.