force method to uppercase (#7514)
Co-authored-by: Mislav Marohnić <mislav@github.com>
This commit is contained in:
parent
7a814b31c2
commit
e4e7bf5c8c
2 changed files with 19 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ func httpRequest(client *http.Client, hostname string, method string, p string,
|
|||
return nil, fmt.Errorf("unrecognized parameters type: %v", params)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, requestURL, body)
|
||||
req, err := http.NewRequest(strings.ToUpper(method), requestURL, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,24 @@ func Test_httpRequest(t *testing.T) {
|
|||
headers: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "lowercase HTTP method",
|
||||
args: args{
|
||||
client: &httpClient,
|
||||
host: "github.com",
|
||||
method: "get",
|
||||
p: "repos/octocat/spoon-knife",
|
||||
params: nil,
|
||||
headers: []string{},
|
||||
},
|
||||
wantErr: false,
|
||||
want: expects{
|
||||
method: "GET",
|
||||
u: "https://api.github.com/repos/octocat/spoon-knife",
|
||||
body: "",
|
||||
headers: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "GET with leading slash",
|
||||
args: args{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue