myhttp

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const UserAgent = "" /* 135-byte string literal not displayed */

UserAgent default

Variables

View Source
var DefaultClient = NewClient()

DefaultClient is the client

Functions

func Base

func Base(url string) string

Base returns the base url of a given url. It works with url or path

func IsAbs

func IsAbs(url string) bool

IsAbs return true with the url is absolute path

func Rel

func Rel(base, target string) string

Rel return the path of target relative to base.

func SetCookieJar

func SetCookieJar(cj *cookiejar.Jar) func(c *Client)

SetCookieJar is configuration function to provide a cookie jar to the client

func SetUserAgent

func SetUserAgent(ua string) func(c *Client)

SetUserAgent is configuration function to give a user agent string to the client

Types

type Client

type Client struct {
	*http.Client

	Jar *cookiejar.Jar
	// contains filtered or unexported fields
}

Client is the classic http client with a cookie jar and a given user agent string

func NewClient

func NewClient(conf ...func(c *Client)) *Client

NewClient create an HTTP Client and configure it with a set of config functions

func (*Client) DoWithContext

func (c *Client) DoWithContext(ctx context.Context, method string, theURL string, headers http.Header, body io.Reader) (io.ReadCloser, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, u string) (io.ReadCloser, error)

Get establish a GET request and return a reader with the response body

type Header struct {
	http.Header
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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