Versions in this module Expand all Collapse all v1 v1.1.1 Jan 16, 2025 Changes in this version + var ErrInvalidCompression = errors.New("unsupported compression type") + var ErrInvalidWriterType = errors.New("invalid writer type") + var ErrMissingFilePath = errors.New("file path must be specified when using WriteToFile") + var ErrUnexpectedFilePath = errors.New("filepath should not be provided when using WriteToBuffer") type Option + func (opt *Option) CreatePayloadReader(payload any) (io.Reader, int64, error) + func (opt *Option) InferContentType(file *os.File, fileInfo os.FileInfo) error + func (opt *Option) Log(msg string, args ...any) v1.0.0 Jan 7, 2025 Changes in this version + func ProgressReader(reader io.Reader, total int64, onProgress func(read, total int64)) *progressReader + func ProgressWriter(writer io.WriteCloser, total int64, onProgress func(written, total int64)) *progressWriter + type CompressionType string + const CompressionBrotli + const CompressionCustom + const CompressionDeflate + const CompressionGzip + const CompressionNone + type Option struct + Compression CompressionType + Cookies []*http.Cookie + CustomCompressionType CompressionType + CustomCompressor func(w *io.PipeWriter) (io.WriteCloser, error) + DownloadBufferSize *int + FollowRedirect bool + Header http.Header + Logger slog.Logger + OnDownloadProgress func(bytesRead, totalBytes int64) + OnUploadProgress func(bytesRead, totalBytes int64) + PreserveMethodOnRedirect bool + ProtocolScheme string + ResponseWriter ResponseWriter + Transport *http.Transport + UniqueIdentifierType UniqueIdentifierType + UploadBufferSize *int + UserAgent string + Verbose bool + func New(opts ...*Option) *Option + func (opt *Option) AddCookie(cookie *http.Cookie) + func (opt *Option) AddHeader(key string, value string) + func (opt *Option) ClearCookies() + func (opt *Option) ClearHeaders() + func (opt *Option) DisableLogging() + func (opt *Option) DisablePreserveMethodOnRedirect() + func (opt *Option) DisableRedirects() + func (opt *Option) EnableLogging() + func (opt *Option) EnablePreserveMethodOnRedirect() + func (opt *Option) EnableRedirects() + func (opt *Option) GenerateIdentifier() string + func (opt *Option) GetCompressor(w *io.PipeWriter) (io.WriteCloser, error) + func (opt *Option) GetWriter() io.WriteCloser + func (opt *Option) InitialiseWriter() (io.WriteCloser, error) + func (opt *Option) ListCookies() + func (opt *Option) ListHeaders() + func (opt *Option) LogVerbose(msg string, args ...any) + func (opt *Option) Merge(src *Option) + func (opt *Option) SetBufferOutput() + func (opt *Option) SetCompression(compressionType CompressionType) + func (opt *Option) SetDownloadBufferSize(sizeInBytes int) + func (opt *Option) SetFileOutput(filepath string) + func (opt *Option) SetLogger(logger *slog.Logger) + func (opt *Option) SetOutput(writerType ResponseWriterType, filepath ...string) error + func (opt *Option) SetProtocolScheme(scheme string) + func (opt *Option) SetTransport(transport *http.Transport) + func (opt *Option) UseJsonLogger() + func (opt *Option) UseTextLogger() + type ResponseWriter struct + FilePath string + Type ResponseWriterType + type ResponseWriterType string + const WriteToBuffer + const WriteToFile + type UniqueIdentifierType string + const IdentifierNone + const IdentifierULID + const IdentifierUUID + type UploadType string + type WriteCloserBuffer struct + func (wcb *WriteCloserBuffer) Close() error Other modules containing this package github.com/caelisco/http-client/v2