httpc

package module
v0.0.0-...-662e364 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HTTPHeaderAccept             = "Accept"
	HTTPHeaderAcceptEncoding     = "Accept-Encoding"
	HTTPHeaderAuthorization      = "Authorization"
	HTTPHeaderCacheControl       = "Cache-Control"
	HTTPHeaderContentDisposition = "Content-Disposition"
	HTTPHeaderContentEncoding    = "Content-Encoding"
	HTTPHeaderContentLength      = "Content-Length"
	HTTPHeaderContentMD5         = "Content-MD5"
	HTTPHeaderContentType        = "Content-Type"
	HTTPHeaderContentLanguage    = "Content-Language"
	HTTPHeaderDate               = "Date"
	HTTPHeaderEtag               = "ETag"
	HTTPHeaderExpires            = "Expires"
	HTTPHeaderHost               = "Host"
	HTTPHeaderLastModified       = "Last-Modified"
	HTTPHeaderRange              = "Range"
	HTTPHeaderLocation           = "Location"
	HTTPHeaderOrigin             = "Origin"
	HTTPHeaderServer             = "Server"
	HTTPHeaderUserAgent          = "User-Agent"
	HTTPHeaderIfModifiedSince    = "If-Modified-Since"
	HTTPHeaderIfUnmodifiedSince  = "If-Unmodified-Since"
	HTTPHeaderIfMatch            = "If-Match"
	HTTPHeaderIfNoneMatch        = "If-None-Match"
)

Http Header name

View Source
const (
	ContentTypeForm = "application/x-www-form-urlencoded"
)

Variables

View Source
var (
	ProxySetting = Proxy{}
)

Functions

func CreateTransport

func CreateTransport(timeout *Timeout, keepAlive bool) (ret *http.Transport)

CreateTransport 创建Transport, timeout可以为nil,使用ProxySetting

func Delete

func Delete(url string, header http.Header, body io.Reader, timeout *Timeout) (*http.Response, error)

func DeleteBytes

func DeleteBytes(url string, header http.Header, body io.Reader, timeout *Timeout) ([]byte, error)

func DeleteJson

func DeleteJson(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func DeleteXml

func DeleteXml(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func Get

func Get(url string, header http.Header, timeout *Timeout) (*http.Response, error)

Get http get command, header, timeout may be nil

func GetBytes

func GetBytes(url string, header http.Header, timeout *Timeout) ([]byte, error)

func GetJson

func GetJson(url string, header http.Header, timeout *Timeout, v interface{}) error

func GetXml

func GetXml(url string, header http.Header, timeout *Timeout, v interface{}) error

func Post

func Post(url string, header http.Header, body io.Reader, timeout *Timeout) (*http.Response, error)

func PostBytes

func PostBytes(url string, header http.Header, body io.Reader, timeout *Timeout) ([]byte, error)

func PostForm

func PostForm(url string, header http.Header, data url.Values, timeout *Timeout) (*http.Response, error)

PostForm ContentType is not included in header. It is added auto.

func PostFormBytes

func PostFormBytes(url string, header http.Header, data url.Values, timeout *Timeout) ([]byte, error)

func PostFormJson

func PostFormJson(url string, header http.Header, data url.Values, timeout *Timeout, v interface{}) error

func PostFormXml

func PostFormXml(url string, header http.Header, data url.Values, timeout *Timeout, v interface{}) error

func PostJson

func PostJson(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func PostXml

func PostXml(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func Put

func Put(url string, header http.Header, body io.Reader, timeout *Timeout) (*http.Response, error)

func PutBytes

func PutBytes(url string, header http.Header, body io.Reader, timeout *Timeout) ([]byte, error)

func PutForm

func PutForm(url string, header http.Header, data url.Values, timeout *Timeout) (*http.Response, error)

PutForm ContentType is not included in header. It is added auto.

func PutFormBytes

func PutFormBytes(url string, header http.Header, data url.Values, timeout *Timeout) ([]byte, error)

func PutFormJson

func PutFormJson(url string, header http.Header, data url.Values, timeout *Timeout, v interface{}) error

func PutFormXml

func PutFormXml(url string, header http.Header, data url.Values, timeout *Timeout, v interface{}) error

func PutJson

func PutJson(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func PutXml

func PutXml(url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func Request

func Request(method, url string, header http.Header, body io.Reader, timeout *Timeout) (*http.Response, error)

Request require a http command.

func RequestBytes

func RequestBytes(method, url string, header http.Header, body io.Reader, timeout *Timeout) ([]byte, error)

func RequestJson

func RequestJson(method, url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

func RequestXml

func RequestXml(method, url string, header http.Header, body io.Reader, timeout *Timeout, v interface{}) error

Types

type Proxy

type Proxy struct {
	Host     string //host name
	User     string //user name for auth. default is "" which means that doesn't use.
	Password string //password for auth.
}

Proxy setting

type Timeout

type Timeout struct {
	Connect time.Duration //connection timeout
	Read    time.Duration //read timeout
	Write   time.Duration //write timeout
	Header  time.Duration //timeout for waiting Response Header
	Idle    time.Duration //timeout for idle
}

Timeout timeout setting. Default is 0 which means that doesn't use and use golang default setting.

Jump to

Keyboard shortcuts

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