session

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package session contains a default implementation of the session browser

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultSession

type DefaultSession struct {
	watcherHttp.Session
	Client      *http.Client
	RateLimiter *rate.Limiter
	MaxRetries  int
	// contains filtered or unexported fields
}

DefaultSession is an extension to the implemented SessionInterface for HTTP sessions

func NewSession

func NewSession(moduleKey string) *DefaultSession

NewSession initializes a new session and sets all the required headers etc

func (*DefaultSession) ApplyRateLimit

func (s *DefaultSession) ApplyRateLimit()

ApplyRateLimit waits for the leaky bucket to fill again

func (*DefaultSession) DownloadFile

func (s *DefaultSession) DownloadFile(filepath string, uri string) (err error)

DownloadFile tries to download the file, returns the occurred error if something went wrong even after multiple tries

func (*DefaultSession) Get

func (s *DefaultSession) Get(uri string) (response *http.Response, err error)

Get sends a GET request, returns the occurred error if something went wrong even after multiple tries

func (*DefaultSession) GetClient

func (s *DefaultSession) GetClient() *http.Client

GetClient returns the used *http.Client, required f.e. to manually set cookies

func (*DefaultSession) Post

func (s *DefaultSession) Post(uri string, data url.Values) (response *http.Response, err error)

Post sends a POST request, returns the occurred error if something went wrong even after multiple tries

func (*DefaultSession) SetClient

func (s *DefaultSession) SetClient(client *http.Client)

SetClient sets the used *http.Client in case we are routing the requests (for f.e. OAuth2 Authentications)

func (*DefaultSession) SetProxy

func (s *DefaultSession) SetProxy(proxySettings *watcherHttp.ProxySettings) (err error)

SetProxy sets the current proxy for the client

Jump to

Keyboard shortcuts

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