request

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionType

type CompressionType string
const (
	CompressionNone    CompressionType = ""
	CompressionGzip    CompressionType = "gzip"
	CompressionDeflate CompressionType = "deflate"
	CompressionBrotli  CompressionType = "br"
)

type Options

type Options struct {
	Headers          []kv.Header          // Custom headers to be added to the request
	Cookies          []*http.Cookie       // Cookies to be included in the request
	ProtocolScheme   string               // define a custom protocol scheme. It defaults to https
	Compression      CompressionType      // CompressionType to use: none, gzip, deflate or brotli
	UserAgent        string               // User Agent to send with requests
	DisableRedirect  bool                 // Disable or enable redirects. Default is false - do not disable redirects
	UniqueIdentifier UniqueIdentifierType // Internal trace or identifier for the request
	Writer           io.WriteCloser       // Define a custom resource you will write to other than the bytes.Buffer i.e.: a file
}

RequestOptions represents additional options for the HTTP request.

DisableRedirect - Determines if redirects should be followed or not. The default option is false which means redirects will be followed.

func NewOptions

func NewOptions() Options

func (*Options) AddCookie

func (opt *Options) AddCookie(cookie *http.Cookie)

AddCookie adds a new cookie to the RequestOptions.

func (*Options) AddHeader

func (opt *Options) AddHeader(key string, value string)

AddHeader adds a new header to the RequestOptions.

func (*Options) ClearCookies

func (opt *Options) ClearCookies()

ClearCookies clears all cookies in the RequestOptions.

func (*Options) ClearHeaders

func (opt *Options) ClearHeaders()

ClearHeaders clears all headers in the RequestOptions.

func (*Options) Compress

func (opt *Options) Compress(compressionType CompressionType)

func (*Options) DisableRedirects

func (opt *Options) DisableRedirects() bool

func (*Options) EnableRedirects

func (opt *Options) EnableRedirects() bool

func (*Options) FileWriter added in v0.4.0

func (opt *Options) FileWriter(filename string) error

func (*Options) GenerateIdentifier added in v0.4.0

func (opt *Options) GenerateIdentifier() string

func (*Options) ListCookies

func (opt *Options) ListCookies()

ListCookies prints out the list of cookies in the RequestOptions.

func (*Options) ListHeaders

func (opt *Options) ListHeaders()

ListHeaders prints out the list of headers in the RequestOptions.

func (*Options) Merge added in v0.4.2

func (opt *Options) Merge(src Options)

func (*Options) SetProtocolScheme

func (opt *Options) SetProtocolScheme(scheme string)

type UniqueIdentifierType added in v0.4.0

type UniqueIdentifierType string
const (
	IdentifierNone UniqueIdentifierType = ""
	IdentifierUUID UniqueIdentifierType = "uuid"
	IdentifierULID UniqueIdentifierType = "ulid"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL