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
|
@ -139,15 +139,16 @@ type Opts struct {
|
||||||
UserName string // username for Basic Auth
|
UserName string // username for Basic Auth
|
||||||
Password string // password for Basic Auth
|
Password string // password for Basic Auth
|
||||||
Options []fs.OpenOption
|
Options []fs.OpenOption
|
||||||
IgnoreStatus bool // if set then we don't check error status or parse error body
|
IgnoreStatus bool // if set then we don't check error status or parse error body
|
||||||
MultipartParams url.Values // if set do multipart form upload with attached file
|
MultipartParams url.Values // if set do multipart form upload with attached file
|
||||||
MultipartMetadataName string // ..this is used for the name of the metadata form part if set
|
MultipartMetadataName string // ..this is used for the name of the metadata form part if set
|
||||||
MultipartContentName string // ..name of the parameter which is the attached file
|
MultipartContentName string // ..name of the parameter which is the attached file
|
||||||
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
|
||||||
Close bool // set to close the connection after this transaction
|
Trailer *http.Header // set the request trailer
|
||||||
NoRedirect bool // if this is set then the client won't follow redirects
|
Close bool // set to close the connection after this transaction
|
||||||
|
NoRedirect bool // if this is set then the client won't follow redirects
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy creates a copy of the options
|
// Copy creates a copy of the options
|
||||||
|
@ -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