goo_http_request

package
v1.1.214 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	TAG = "goo-http-request"

	CONTENT_TYPE_XML  = "application/xml"
	CONTENT_TYPE_JSON = "application/json"
	CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func Download added in v1.1.132

func Download(url, filename string) error

func Exists added in v1.1.195

func Exists(url string) (bool, error)

func GPTStream added in v1.1.116

func GPTStream(url string, data []byte, cb func(b []byte)) error

func Get

func Get(url string) ([]byte, error)

func GetWithQuery added in v1.0.25

func GetWithQuery(url string, data []byte) ([]byte, error)

func Post

func Post(url string, data []byte) ([]byte, error)

func PostJson

func PostJson(url string, data []byte) ([]byte, error)

func Put

func Put(url string, data []byte) ([]byte, error)

func Upload

func Upload(url, fileField, fileName string, fh io.Reader, data map[string]string) (b []byte, err error)

Types

type Option

type Option struct {
	Name  string
	Value interface{}
}

func ContentTypeFormOption

func ContentTypeFormOption() Option

func ContentTypeJsonOption

func ContentTypeJsonOption() Option

func ContentTypeXmlOption

func ContentTypeXmlOption() Option

func DebugOption

func DebugOption() Option

func HeaderOption

func HeaderOption(field, value string) Option

func TlsOption

func TlsOption(caCrtFile, clientCrtFile, clientKeyFile string) Option

type Request

type Request struct {
	Headers map[string]string
	Tls     *Tls
	// contains filtered or unexported fields
}

func Debug added in v1.0.18

func Debug() *Request

func New

func New(opts ...Option) *Request

func SetHeader added in v1.0.18

func SetHeader(name, value string) *Request

func (*Request) Debug

func (r *Request) Debug() *Request

func (*Request) Do

func (r *Request) Do(method, url string, reader io.Reader) (rst []byte, err error)

func (*Request) Download added in v1.1.132

func (r *Request) Download(url, filename string) (err error)

func (*Request) GPTStream added in v1.1.116

func (r *Request) GPTStream(url string, data []byte, cb func(b []byte)) error

func (*Request) Get

func (r *Request) Get(url string) ([]byte, error)

func (*Request) GetWithQuery added in v1.0.25

func (r *Request) GetWithQuery(url string, data []byte) ([]byte, error)

func (*Request) JsonContentType

func (r *Request) JsonContentType() *Request

func (*Request) Post

func (r *Request) Post(url string, data []byte) ([]byte, error)

func (*Request) PostJson added in v1.0.19

func (r *Request) PostJson(url string, data []byte) ([]byte, error)

func (*Request) Put

func (r *Request) Put(url string, data []byte) ([]byte, error)

func (*Request) SetContentType

func (r *Request) SetContentType(contentType string) *Request

func (*Request) SetHeader added in v1.0.18

func (r *Request) SetHeader(name, value string) *Request

func (*Request) SetTimeout added in v1.0.3

func (r *Request) SetTimeout(d time.Duration) *Request

func (*Request) Upload added in v1.0.6

func (r *Request) Upload(url, fileField, fileName string, fh io.Reader, data map[string]string) ([]byte, error)

type Tls

type Tls struct {
	CaCrtFile     string
	ClientCrtFile string
	ClientKeyFile string
}

func (*Tls) CaCrt

func (s *Tls) CaCrt() []byte

func (*Tls) ClientCrt

func (s *Tls) ClientCrt() tls.Certificate

Jump to

Keyboard shortcuts

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