Skip to content

Commit 30f1bf2

Browse files
committed
Add missing Client method
1 parent 9b80776 commit 30f1bf2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"io"
66
"net/http"
7+
"net/url"
8+
"strings"
79
)
810

911
// Client represents an HTTP client that optionally signs requests and optionally verifies responses.
@@ -108,3 +110,8 @@ func (c *Client) Post(url, contentType string, body io.Reader) (res *http.Respon
108110
req.Header.Set("Content-Type", contentType)
109111
return c.Do(req)
110112
}
113+
114+
// PostForm sends an HTTP POST, with data keys and values URL-encoded as the request body.
115+
func (c *Client) PostForm(url string, data url.Values) (resp *http.Response, err error) {
116+
return c.Post(url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode()))
117+
}

client_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ func TestClient_Head(t *testing.T) {
188188
wantErr bool
189189
}{
190190
{
191-
name: "TLS",
191+
name: "Happy Path",
192192
fields: fields{
193193
sigName: "sig1",
194194
signer: func() *Signer {
195-
signer, _ := NewHMACSHA256Signer("key1", bytes.Repeat([]byte{1}, 64), NewSignConfig(), Headers("@method"))
195+
signer, _ := NewHMACSHA256Signer("key1", bytes.Repeat([]byte{1}, 64), NewSignConfig(),
196+
Headers("@method"))
196197
return signer
197198
}(),
198199
verifier: nil,

0 commit comments

Comments
 (0)