http

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package http contains the basic HTTP functionality of the application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProxySettings

type ProxySettings struct {
	Enable   bool   `mapstructure:"enable"`
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

ProxySettings are the proxy server settings for the session

type Session

type Session struct {
	SessionInterface
	ModuleKey string
}

Session is an implementation to the SessionInterface to provide basic functions

func (*Session) CheckDownloadedFileForErrors

func (s *Session) CheckDownloadedFileForErrors(writtenSize int64, responseHeader http.Header) (err error)

CheckDownloadedFileForErrors compares the downloaded file with the content length header of the request if set also checks if the written bytes are more not equal or less than 0 which is definitely an unwanted result

func (*Session) EnsureDownloadDirectory

func (s *Session) EnsureDownloadDirectory(fileName string)

EnsureDownloadDirectory ensures that the download path already exists or creates it if not this function panics when path can't be created

func (*Session) GetDocument

func (s *Session) GetDocument(response *http.Response) *goquery.Document

GetDocument converts the http response to a *goquery.Document

func (*Session) UpdateTreeFolderChangeTimes

func (s *Session) UpdateTreeFolderChangeTimes(filePath string)

UpdateTreeFolderChangeTimes recursively updates the folder access and modification times to indicate changes in the data for file explorers

type SessionInterface

type SessionInterface interface {
	Get(uri string) (response *http.Response, err error)
	Post(uri string, data url.Values) (response *http.Response, err error)
	DownloadFile(filepath string, uri string) (err error)
	EnsureDownloadDirectory(fileName string)
	CheckDownloadedFileForErrors(writtenSize int64, responseHeader http.Header) (err error)
	GetDocument(response *http.Response) *goquery.Document
	GetClient() *http.Client
	UpdateTreeFolderChangeTimes(filePath string)
	SetProxy(proxySettings *ProxySettings) (err error)
	SetClient(client *http.Client)
}

SessionInterface of used functions from the application to eventually change the underlying library

Directories

Path Synopsis
Package session contains a default implementation of the session browser
Package session contains a default implementation of the session browser

Jump to

Keyboard shortcuts

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