force method to uppercase (#7514)

Co-authored-by: Mislav Marohnić <mislav@github.com>
This commit is contained in:
ffalor 2023-06-01 08:54:56 -05:00 committed by GitHub
parent 7a814b31c2
commit e4e7bf5c8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -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
}

View file

@ -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{