package req

import (
	
	
	
	
)

type kv struct {
	Key   string
	Value string
}

// ContentDisposition represents parameters in `Content-Disposition`
// MIME header of multipart request.
type ContentDisposition struct {
	kv []kv
}

// Add adds a new key-value pair of Content-Disposition
func ( *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" multipart
type FileUpload struct {
	// "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.
type UploadInfo struct {
	// 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.
type UploadCallback func(info UploadInfo)

// DownloadInfo is the information for each DownloadCallback call.
type DownloadInfo struct {
	// 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.
type DownloadCallback func(info DownloadInfo)

func cloneSlice[ any]( []) [] {
	if len() == 0 {
		return nil
	}
	 := make([], len())
	copy(, )
	return 
}

func cloneUrlValues( url.Values) url.Values {
	if  == nil {
		return nil
	}
	 := make(url.Values)
	for ,  := range  {
		for ,  := range  {
			.Add(, )
		}
	}
	return 
}

func cloneMap( map[string]string) map[string]string {
	if  == nil {
		return nil
	}
	 := 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()
}