Skip to content

Commit c87811a

Browse files
committed
Add support for additional HTTP methods***
1 parent 4ea2ab9 commit c87811a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

httpclient/httpclient_methods.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// httpclient_methods.go
2+
package httpclient
3+
24
/* Ref: https://www.rfc-editor.org/rfc/rfc7231#section-8.1.3
35
46
+---------+------+------------+
@@ -12,18 +14,20 @@
1214
| POST | no | no |
1315
| PUT | no | yes |
1416
| TRACE | yes | yes |
15-
+---------+------+------------+
17+
+---------+------+------------+
1618
*/
17-
package httpclient
1819

1920
import "net/http"
2021

2122
// IsIdempotentHTTPMethod checks if the given HTTP method is idempotent.
2223
func 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.
3438
func 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]

0 commit comments

Comments
 (0)