Skip to content

Commit ecf7555

Browse files
authored
Merge pull request #31 from cedrickah/feature/block-get-and-head-body
feat: block body when request method is GET or HEAD
2 parents b1c3031 + ae960d1 commit ecf7555

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

get.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ func Get(url string, config ...interface{}) (*Response, error) {
99
return nil, ErrTooManyArguments
1010
}
1111

12+
if c.Body != nil {
13+
panic("Request with GET method cannot have body")
14+
}
15+
1216
return New().Get(url, c).Execute()
1317
}

head.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ func Head(url string, config ...interface{}) (*Response, error) {
99
return nil, ErrTooManyArguments
1010
}
1111

12+
if c.Body != nil {
13+
panic("Request with HEAD method cannot have body")
14+
}
15+
1216
return New().Head(url, c).Execute()
1317
}

0 commit comments

Comments
 (0)