utilmagic

package
v0.0.0-...-842eef1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HEADER_CONTENT_ENCODING = "Content-Encoding"

	VERSION           = "0.0.1"
	DEFAULT_USERAGENT = "gomagic httpclient - " + VERSION

	PROXY_HTTP    = "HTTP"
	PROXY_SOCKS4  = "SOCKS4"
	PROXY_SOCKS5  = "SOCKS5"
	PROXY_SOCKS4A = "SOCKS4A"

	DEFAULT_ST_CONNECTTIMEOUT = 60
	DEFAULT_ST_TIMEOUT        = 60
	DEFAULT_ST_COOKIEJAR      = true
)

Variables

View Source
var (
	HTTPMETHOD = map[string]string{
		"DELETE": "DELETE",
		"HEAD":   "HEAD",
		"GET":    "GET",
		"POST":   "POST",
		"PUT":    "PUT",
	}
)

Functions

func FileExists

func FileExists(name string) bool

func MapMerge

func MapMerge(maps ...map[string]string) map[string]string

func MapToString

func MapToString(map_ map[string]string) string

Types

type Headers

type Headers map[string]string

type HttpClient

type HttpClient struct {
	Headers   map[string]string
	Settings  map[string]interface{}
	Transport http.RoundTripper

	CookieJar http.CookieJar
	// contains filtered or unexported fields
}

func CustomHttpClient

func CustomHttpClient(settings Settings, headers Headers) *HttpClient

func DefaultHttpClinet

func DefaultHttpClinet() *HttpClient

func (*HttpClient) AddHeader

func (h *HttpClient) AddHeader(key, value string)

func (*HttpClient) Delete

func (h *HttpClient) Delete(url string, params map[string]string) (*Resp,
	error)

func (*HttpClient) Get

func (h *HttpClient) Get(url string, params map[string]string) (*Resp,
	error)

func (*HttpClient) Head

func (h *HttpClient) Head(url string, params map[string]string) (*Resp,
	error)

func (*HttpClient) Post

func (h *HttpClient) Post(url string, params map[string]string) (*Resp,
	error)

func (*HttpClient) Put

func (h *HttpClient) Put(url string, params map[string]string) (*Resp, error)

func (*HttpClient) Request

func (h *HttpClient) Request(method string, url string, headers map[string]string,
	body io.Reader) (*Resp, error)

type Resp

type Resp struct {
	*http.Response
}

func (*Resp) ReadBytes

func (r *Resp) ReadBytes() ([]byte, error)

func (*Resp) ReadString

func (r *Resp) ReadString() (string, error)

type Settings

type Settings map[string]interface{}

Jump to

Keyboard shortcuts

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