Documentation ¶
Overview ¶
pkg/common/requests/download.go
pkg/common/requests/progress.go
pkg/common/requests/requests.go
Index ¶
- Constants
- func DecodeJSON(body []byte, result interface{}) error
- func SetFormURLEncodedPayload(req *http.Request, data interface{}) error
- func SetJSONPayload(req *http.Request, data interface{}) error
- func SetQueryParams(req *http.Request, query interface{})
- func SetXMLPayload(req *http.Request, data interface{}) error
- type Client
- func (c *Client) CreateRequest(method string, url string) (*http.Request, error)
- func (c *Client) DoRequest(method string, url string, query interface{}, data interface{}) (*http.Response, []byte, error)
- func (c *Client) DownloadFile(url, directory, filename string, allowDuplicates bool) error
- func (c *Client) ExtractParam(u, parameter string) string
- func (c *Client) UpdateBodyType(bodyType string)
- func (c *Client) UpdateContentType(contentType string)
- type DownloadMetadata
- type Headers
- type Paginator
Constants ¶
View Source
const ( All = "*/*" // RFC-7231 (https://www.rfc-editor.org/rfc/rfc7231.html) Atom = "application/atom+xml" // RFC-4287 (https://www.rfc-editor.org/rfc/rfc4287.html) CSS = "text/css" // RFC-2318 (https://www.rfc-editor.org/rfc/rfc2318.html) Excel = "application/vnd.ms-excel" // Proprietary FormURLEncoded = "application/x-www-form-urlencoded" // RFC-1866 (https://www.rfc-editor.org/rfc/rfc1866.html) GIF = "image/gif" // RFC-2046 (https://www.rfc-editor.org/rfc/rfc2046.html) HTML = "text/html" // RFC-2854 (https://www.rfc-editor.org/rfc/rfc2854.html) JPEG = "image/jpeg" // RFC-2045 (https://www.rfc-editor.org/rfc/rfc2045.html) JavaScript = "text/javascript" // RFC-9239 (https://www.rfc-editor.org/rfc/rfc9239.html) JSON = "application/json" // RFC-8259 (https://www.rfc-editor.org/rfc/rfc8259.html) MP3 = "audio/mpeg" // RFC-3003 (https://www.rfc-editor.org/rfc/rfc3003.html) MP4 = "video/mp4" // RFC-4337 (https://www.rfc-editor.org/rfc/rfc4337.html) MPEG = "video/mpeg" // RFC-4337 (https://www.rfc-editor.org/rfc/rfc4337.html) MultipartFormData = "multipart/form-data" // RFC-7578 (https://www.rfc-editor.org/rfc/rfc7578.html) OctetStream = "application/octet-stream" // RFC-2046 (https://www.rfc-editor.org/rfc/rfc2046.html) PDF = "application/pdf" // RFC-3778 (https://www.rfc-editor.org/rfc/rfc3778.html) PNG = "image/png" // RFC-2083 (https://www.rfc-editor.org/rfc/rfc2083.html) Plain = "text/plain" // RFC-2046 (https://www.rfc-editor.org/rfc/rfc2046.html) RSS = "application/rss+xml" // RFC-7303 (https://www.rfc-editor.org/rfc/rfc4287.html) WAV = "audio/wav" // RFC-2361 (https://www.rfc-editor.org/rfc/rfc2361.html) XML = "application/xml" // RFC-7303 (https://www.rfc-editor.org/rfc/rfc7303.html) YAML = "application/yaml" // RFC-9512 (https://www.rfc-editor.org/rfc/rfc9512.html) ZIP = "application/zip" // RFC-1951 (https://www.rfc-editor.org/rfc/rfc1951.html) )
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
* DecodeJSON * @param body []byte * @param result interface{} * @return error
func SetJSONPayload ¶
func SetQueryParams ¶
func SetXMLPayload ¶
Types ¶
type Client ¶
type Client struct { BodyType string Cache *cache.Cache Headers Headers Log *log.Logger RateLimiter *rl.RateLimiter // contains filtered or unexported fields }
* Client * @param httpClient *http.Client * @param headers Headers
func (*Client) CreateRequest ¶
func (*Client) DownloadFile ¶
func (*Client) ExtractParam ¶
func (*Client) UpdateBodyType ¶
UpdateHeaders changes the payload body for the HTTP client
func (*Client) UpdateContentType ¶
UpdateHeaders changes the headers for the HTTP client
type DownloadMetadata ¶
type DownloadMetadata struct { URL string // Source URL FilePath string // Full path to the downloaded file FileName string // Name of the file BytesReceived int64 // Bytes downloaded so far TotalSize int64 // Total size of the file LastModified time.Time // Last modified time from server Checksum string // For checksum validation (optional) }
DownloadMetadata stores state for managing downloads.
Click to show internal directories.
Click to hide internal directories.