Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Delete(strUrl string) (response *Response, err error)
- func (c *Client) Get(strUrl string, values UrlValues) (response *Response, err error)
- func (c *Client) Header() *Header
- func (c *Client) Patch(strUrl string) (response *Response, err error)
- func (c *Client) Post(strUrl string, data interface{}) (response *Response, err error)
- func (c *Client) PostUrlEncoded(strUrl string, values UrlValues) (response *Response, err error)
- func (c *Client) Put(strUrl string) (response *Response, err error)
- func (c *Client) Trace(strUrl string) (response *Response, err error)
- type Header
- func (h *Header) Delete(strKey string)
- func (h *Header) Get(strKey string) (strValue string)
- func (h *Header) RemoveAll()
- func (h *Header) Set(strKey, strValue string) *Header
- func (h *Header) SetApplicationJson() *Header
- func (h *Header) SetAuthorization(strValue string) *Header
- func (h *Header) SetMultipartFormData() *Header
- func (h *Header) SetTextHtml() *Header
- func (h *Header) SetTextPlain() *Header
- func (h *Header) SetUrlEncoded() *Header
- type HttpServer
- type Response
- type UrlValues
Constants ¶
View Source
const ( HTTP_METHOD_GET = "GET" //请求指定的页面信息,并返回实体主体。 HTTP_METHOD_POST = "POST" //向指定资源提交数据进行处理请求(例如提交表单或者上传文件)。数据被包含在请求体中。POST 请求可能会导致新的资源的建立和/或已有资源的修改。 HTTP_METHOD_PUT = "PUT" //从客户端向服务器传送的数据取代指定的文档的内容。 HTTP_METHOD_CONNECT = "CONNECT" //HTTP/1.1 协议中预留给能够将连接改为管道方式的代理服务器 HTTP_METHOD_OPTIONS = "OPTIONS" //允许客户端查看服务器的性能。 HTTP_METHOD_DELETE = "DELETE" //请求服务器删除指定的页面内容。 HTTP_METHOD_TRACE = "TRACE" //回显服务器收到的请求,主要用于测试或诊断。 HTTP_METHOD_PATCH = "PATCH" //是对PUT方法的补充,用来对已知资源进行局部更新。 HTTP_METHOD_HEAD = "HEAD" //类似于GET请求,只不过返回的响应中没有具体的内容,用于获取报头 )
View Source
const ( HEADER_KEY_CONTENT_TYPE = "Content-Type" HEADER_KEY_AUTHORIZATION = "Authorization" )
View Source
const ( CONTENT_TYPE_NAME_TEXT_PLAIN = "text/plain" //content-type (raw) CONTENT_TYPE_NAME_MULTIPART_FORM_DATA = "multipart/form-data" //content-type (form-data) CONTENT_TYPE_NAME_X_WWW_FORM_URL_ENCODED = "application/x-www-form-urlencoded" //content-type (urlencoded) CONTENT_TYPE_NAME_APPLICATION_JSON = "application/json" //content-type (json) CONTENT_TYPE_NAME_TEXT_HTML = "text/html" //content-type (html) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewHttpsClient ¶
新建一个HTTPS客户端对象 timeout 连接超时秒数 cer PEM证书文件路径(string)或二进制数据([]byte)
func (*Client) Post ¶
发起HTTP POST请求(send a http request by POST method with content-type multipart/form-data or application/x-www-form-urlencoded) data 类型 string、[]byte、UrlValues或结构体[对象或引用]
func (*Client) PostUrlEncoded ¶
发起HTTP POST请求(send a http request by POST method with application/x-www-form-urlencoded)
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func (*Header) SetApplicationJson ¶
设置http请求头部内容类型(Content-Type=application/json)
func (*Header) SetAuthorization ¶
设置http请求头部key="Authorization" value=strValue
func (*Header) SetMultipartFormData ¶
设置http请求头部内容类型(Content-Type=multipart/form-data)
func (*Header) SetTextHtml ¶
设置http请求头部内容类型(Content-Type=text/html)
func (*Header) SetTextPlain ¶
设置http请求头部内容类型(Content-Type=text/plain)
func (*Header) SetUrlEncoded ¶
设置http请求头部内容类型(Content-Type=application/x-www-form-urlencoded)
Click to show internal directories.
Click to hide internal directories.