File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 11// httpclient_methods.go
2+ package httpclient
3+
24/* Ref: https://www.rfc-editor.org/rfc/rfc7231#section-8.1.3
35
46+---------+------+------------+
1214| POST | no | no |
1315| PUT | no | yes |
1416| TRACE | yes | yes |
15- +---------+------+------------+
17+ +---------+------+------------+
1618*/
17- package httpclient
1819
1920import "net/http"
2021
2122// IsIdempotentHTTPMethod checks if the given HTTP method is idempotent.
2223func IsIdempotentHTTPMethod (method string ) bool {
2324 idempotentHTTPMethods := map [string ]bool {
24- http .MethodGet : true ,
25- http .MethodPut : true ,
26- http .MethodDelete : true ,
25+ http .MethodGet : true ,
26+ http .MethodPut : true ,
27+ http .MethodDelete : true ,
28+ http .MethodHead : true ,
29+ http .MethodOptions : true ,
30+ http .MethodTrace : true ,
2731 }
2832
2933 return idempotentHTTPMethods [method ]
@@ -33,8 +37,9 @@ func IsIdempotentHTTPMethod(method string) bool {
3337// PATCH can be idempotent but often isn't used as such.
3438func IsNonIdempotentHTTPMethod (method string ) bool {
3539 nonIdempotentHTTPMethods := map [string ]bool {
36- http .MethodPost : true ,
37- http .MethodPatch : true ,
40+ http .MethodPost : true ,
41+ http .MethodPatch : true ,
42+ http .MethodConnect : true ,
3843 }
3944
4045 return nonIdempotentHTTPMethods [method ]
You can’t perform that action at this time.
0 commit comments