35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
|
|
package starnet
|
||
|
|
|
||
|
|
import "net/http"
|
||
|
|
|
||
|
|
// SetBasicAuth 设置 Basic 认证
|
||
|
|
func (r *Request) SetBasicAuth(username, password string) *Request {
|
||
|
|
return r.applyMutation(mutateBasicAuth(username, password))
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetContentLength 设置 Content-Length
|
||
|
|
func (r *Request) SetContentLength(length int64) *Request {
|
||
|
|
return r.applyMutation(mutateContentLength(length))
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetAutoCalcContentLength 设置是否自动计算 Content-Length
|
||
|
|
// 警告:启用后会将整个 body 读入内存
|
||
|
|
func (r *Request) SetAutoCalcContentLength(auto bool) *Request {
|
||
|
|
return r.applyMutation(mutateAutoCalcContentLength(auto))
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetTransport 设置自定义 Transport
|
||
|
|
func (r *Request) SetTransport(transport *http.Transport) *Request {
|
||
|
|
return r.applyMutation(mutateTransport(transport))
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetUploadProgress 设置文件上传进度回调
|
||
|
|
func (r *Request) SetUploadProgress(fn UploadProgressFunc) *Request {
|
||
|
|
return r.applyMutation(mutateUploadProgress(fn))
|
||
|
|
}
|
||
|
|
|
||
|
|
// SetMaxRespBodyBytes 设置响应体最大读取字节数(<=0 表示不限制)
|
||
|
|
func (r *Request) SetMaxRespBodyBytes(maxBytes int64) *Request {
|
||
|
|
return r.applyMutation(mutateMaxRespBodyBytes(maxBytes))
|
||
|
|
}
|