lib/rest: add support for setting trailers
This commit is contained in:
parent
5dd51e6149
commit
47f9ab2f56
1 changed files with 13 additions and 9 deletions
|
@ -146,6 +146,7 @@ type Opts struct {
|
||||||
MultipartFileName string // ..name of the file for the attached file
|
MultipartFileName string // ..name of the file for the attached file
|
||||||
Parameters url.Values // any parameters for the final URL
|
Parameters url.Values // any parameters for the final URL
|
||||||
TransferEncoding []string // transfer encoding, set to "identity" to disable chunked encoding
|
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
|
Close bool // set to close the connection after this transaction
|
||||||
NoRedirect bool // if this is set then the client won't follow redirects
|
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 {
|
if len(opts.TransferEncoding) != 0 {
|
||||||
req.TransferEncoding = opts.TransferEncoding
|
req.TransferEncoding = opts.TransferEncoding
|
||||||
}
|
}
|
||||||
|
if opts.Trailer != nil {
|
||||||
|
req.Trailer = *opts.Trailer
|
||||||
|
}
|
||||||
if opts.Close {
|
if opts.Close {
|
||||||
req.Close = true
|
req.Close = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue