lib/rest: add support for setting trailers

This commit is contained in:
Nil Alexandrov 2021-10-14 18:01:46 -04:00 committed by Nick Craig-Wood
parent 5dd51e6149
commit 47f9ab2f56
1 changed files with 13 additions and 9 deletions

View File

@ -146,6 +146,7 @@ type Opts struct {
MultipartFileName string // ..name of the file for the attached file
Parameters url.Values // any parameters for the final URL
TransferEncoding []string // transfer encoding, set to "identity" to disable chunked encoding
Trailer *http.Header // set the request trailer
Close bool // set to close the connection after this transaction
NoRedirect bool // if this is set then the client won't follow redirects
}
@ -239,6 +240,9 @@ func (api *Client) Call(ctx context.Context, opts *Opts) (resp *http.Response, e
if len(opts.TransferEncoding) != 0 {
req.TransferEncoding = opts.TransferEncoding
}
if opts.Trailer != nil {
req.Trailer = *opts.Trailer
}
if opts.Close {
req.Close = true
}