package reqimport ()type kv struct { Key string Value string}// ContentDisposition represents parameters in `Content-Disposition`// MIME header of multipart request.typeContentDispositionstruct { kv []kv}// Add adds a new key-value pair of Content-Dispositionfunc ( *ContentDisposition) (, string) *ContentDisposition { .kv = append(.kv, kv{Key: , Value: })return}func ( *ContentDisposition) () string {if == nil {return"" } := ""for , := range .kv { += fmt.Sprintf("; %s=%q", .Key, .Value) }return}// FileUpload represents a "form-data" multiparttypeFileUploadstruct {// "name" parameter in `Content-Disposition` ParamName string// "filename" parameter in `Content-Disposition` FileName string// The file to be uploaded. GetFileContent GetContentFunc// Optional file length in bytes. FileSize int64// Optional Content-Type ContentType string// Optional extra ContentDisposition parameters. // According to the HTTP specification, this should be nil, // but some servers may not follow the specification and // requires `Content-Disposition` parameters more than just // "name" and "filename". ExtraContentDisposition *ContentDisposition}// UploadInfo is the information for each UploadCallback call.typeUploadInfostruct {// parameter name in multipart upload ParamName string// filename in multipart upload FileName string// total file length in bytes. FileSize int64// uploaded file length in bytes. UploadedSize int64}// UploadCallback is the callback which will be invoked during// multipart upload.typeUploadCallbackfunc(info UploadInfo)// DownloadInfo is the information for each DownloadCallback call.typeDownloadInfostruct {// Response is the corresponding Response during download. Response *Response// downloaded body length in bytes. DownloadedSize int64}// DownloadCallback is the callback which will be invoked during// response body download.typeDownloadCallbackfunc(info DownloadInfo)func cloneSlice[ any]( []) [] {iflen() == 0 {returnnil } := make([], len())copy(, )return}func cloneUrlValues( url.Values) url.Values {if == nil {returnnil } := make(url.Values)for , := range {for , := range { .Add(, ) } }return}func cloneMap( map[string]string) map[string]string {if == nil {returnnil } := make(map[string]string)for , := range { [] = }return}// convertHeaderToString converts http header to a string.func convertHeaderToString( http.Header) string {if == nil {return"" } := new(bytes.Buffer) .Write()return .String()}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.