httpclient

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient struct {
	// contains filtered or unexported fields
}

HTTPClient define a http client for request.

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient get a new HTTPClient.

func (*HTTPClient) DELETE

func (client *HTTPClient) DELETE(url string, header http.Header, data []byte) ([]byte, error)

DELETE do the delete request and return body.

func (*HTTPClient) Delete

func (client *HTTPClient) Delete(url string, header http.Header, data []byte) (*HttpResponse, error)

Delete do the delete request and return HttpResponse.

func (*HTTPClient) GET

func (client *HTTPClient) GET(url string, header http.Header, data []byte) ([]byte, error)

GET do the get request and return body.

func (*HTTPClient) Get

func (client *HTTPClient) Get(url string, header http.Header, data []byte) (*HttpResponse, error)

Get do the get request and return HttpResponse.

func (*HTTPClient) GetClient

func (client *HTTPClient) GetClient() *http.Client

GetClient return the original http.Client.

func (*HTTPClient) NewTransPort

func (client *HTTPClient) NewTransPort() *http.Transport

NewTransPort get a new http transport.

func (*HTTPClient) PATCH

func (client *HTTPClient) PATCH(url string, header http.Header, data []byte) ([]byte, error)

PATCH do the patch request and return body.

func (*HTTPClient) POST

func (client *HTTPClient) POST(url string, header http.Header, data []byte) ([]byte, error)

POST do the post request and return body.

func (*HTTPClient) PUT

func (client *HTTPClient) PUT(url string, header http.Header, data []byte) ([]byte, error)

PUT do the put request and return body.

func (*HTTPClient) Patch

func (client *HTTPClient) Patch(url string, header http.Header, data []byte) (*HttpResponse, error)

Patch do the patch request and return HttpResponse.

func (*HTTPClient) Post

func (client *HTTPClient) Post(url string, header http.Header, data []byte) (*HttpResponse, error)

Post do the post request and return HttpResponse.

func (*HTTPClient) Put

func (client *HTTPClient) Put(url string, header http.Header, data []byte) (*HttpResponse, error)

Put do the put request and return HttpResponse.

func (*HTTPClient) Request

func (client *HTTPClient) Request(url, method string, header http.Header, data []byte) ([]byte, error)

Request do request and return body.

func (*HTTPClient) RequestEx

func (client *HTTPClient) RequestEx(url, method string, header http.Header, data []byte) (*HttpResponse, error)

RequestEx do request and return HttpResponse.

func (*HTTPClient) SetBatchHeader

func (client *HTTPClient) SetBatchHeader(headerSet []*http2.HeaderSet)

SetBatchHeader batch set header for the http client。 Note:if the header is the same with the parameter(header) which is specified in the function GET, POST, PUT,DELETE,Patch and so on. this set header is ignore in the call

func (*HTTPClient) SetHeader

func (client *HTTPClient) SetHeader(key, value string)

SetHeader set header for the http client。 Note:if the header is the same with the parameter(header) which is specified in the function GET, POST, PUT,DELETE,Patch and so on. this set header is ignore in the call

func (*HTTPClient) SetTLSNoVerity

func (client *HTTPClient) SetTLSNoVerity() error

SetTLSNoVerity set client TLS insecure skip verify

func (*HTTPClient) SetTLSVerity

func (client *HTTPClient) SetTLSVerity(caFile, certFile, keyFile, passwd string) error

SetTLSVerity set client TLS with certs files.

func (*HTTPClient) SetTLSVerityConfig

func (client *HTTPClient) SetTLSVerityConfig(tlsConf *tls.Config)

SetTLSVerityConfig set client TLS with tls.Config.

func (*HTTPClient) SetTLSVerityServer

func (client *HTTPClient) SetTLSVerityServer(caFile string) error

SetTLSVerityServer set server TLS.

func (*HTTPClient) SetTimeOut

func (client *HTTPClient) SetTimeOut(timeOut time.Duration)

SetTimeout set the client timeout.

type HttpResponse

type HttpResponse struct {
	Reply      []byte
	StatusCode int
	Status     string
	Header     http.Header
}

HttpResponse define the information of the http response

Jump to

Keyboard shortcuts

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