Skip to content

Commit

Permalink
lib/http: add method Head to Client
Browse files Browse the repository at this point in the history
The Head method send the HEAD request to path, with optional
headers, and params in query parameters.
  • Loading branch information
shuLhan committed Jan 18, 2024
1 parent 3f26ff7 commit dbfc158
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ func (client *Client) Get(requestPath string, headers http.Header, params url.Va
return client.doRequest(http.MethodGet, headers, requestPath, ``, nil)
}

// Head send the HEAD request to path, with optional headers and params in
// query parameters.
// The returned resBody shoule be always nil.
func (client *Client) Head(path string, headers http.Header, params url.Values) (
httpRes *http.Response, resBody []byte, err error,
) {
if params != nil {
path += `?` + params.Encode()
}
return client.doRequest(http.MethodHead, headers, path, ``, nil)
}

// Post send the POST request to path without setting "Content-Type".
// If the params is not nil, it will send as query parameters in the path.
func (client *Client) Post(requestPath string, headers http.Header, params url.Values) (
Expand Down

0 comments on commit dbfc158

Please sign in to comment.