session

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth request's Authorization header

type CtxArg

type CtxArg string
const (
	CtxSourceArg CtxArg = "source"
)

type Session

type Session struct {
	//UrlExtractor
	Extractor extractor.UrlExtractor
	// Client is the current http client
	Client           *http.Client
	MultiRateLimiter *ratelimit.MultiLimiter
}

Session is the option passed to the source, an option is created uniquely for each source.

func NewSession

func NewSession(query string, proxy string, multiRateLimiter *ratelimit.MultiLimiter, timeout int) (*Session, error)

NewSession creates a new session object for a url

func (*Session) Close

func (s *Session) Close()

Close the session

func (*Session) DiscardHTTPResponse

func (s *Session) DiscardHTTPResponse(response *http.Response)

DiscardHTTPResponse discards the response content by demand

func (*Session) Get

func (s *Session) Get(ctx context.Context, getURL, cookies string, headers map[string]string) (*http.Response, error)

Get makes a GET request to a URL with extended parameters

func (*Session) HTTPRequest

func (s *Session) HTTPRequest(ctx context.Context, method, requestURL, cookies string, headers map[string]string, body io.Reader, basicAuth BasicAuth) (*http.Response, error)

HTTPRequest makes any HTTP request to a URL with extended parameters

func (*Session) Post

func (s *Session) Post(ctx context.Context, postURL, cookies string, headers map[string]string, body io.Reader) (*http.Response, error)

Post makes a POST request to a URL with extended parameters

func (*Session) SimpleGet

func (s *Session) SimpleGet(ctx context.Context, getURL string) (*http.Response, error)

SimpleGet makes a simple GET request to a URL

func (*Session) SimplePost

func (s *Session) SimplePost(ctx context.Context, postURL, contentType string, body io.Reader) (*http.Response, error)

SimplePost makes a simple POST request to a URL

Jump to

Keyboard shortcuts

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