mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 23:01:28 +00:00
Update README
This commit is contained in:
parent
e70537f8b3
commit
6ae8bc1a16
@ -10,8 +10,8 @@ you can use Get to crawl data.
|
|||||||
|
|
||||||
str, err := httplib.Get("http://beego.me/").String()
|
str, err := httplib.Get("http://beego.me/").String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
fmt.Println(str)
|
fmt.Println(str)
|
||||||
|
|
||||||
## POST
|
## POST
|
||||||
@ -22,8 +22,8 @@ POST data to remote url
|
|||||||
req.Param("password","123456")
|
req.Param("password","123456")
|
||||||
str, err := req.String()
|
str, err := req.String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
fmt.Println(str)
|
fmt.Println(str)
|
||||||
|
|
||||||
## Set timeout
|
## Set timeout
|
||||||
@ -32,7 +32,8 @@ The default timeout is `60` seconds, function prototype:
|
|||||||
|
|
||||||
SetTimeout(connectTimeout, readWriteTimeout time.Duration)
|
SetTimeout(connectTimeout, readWriteTimeout time.Duration)
|
||||||
|
|
||||||
Exmaple:
|
Exmaple:
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
|
httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
|
||||||
|
|
||||||
@ -49,10 +50,10 @@ If you want to debug the request info, set the debug on
|
|||||||
## Set HTTP Basic Auth
|
## Set HTTP Basic Auth
|
||||||
|
|
||||||
str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String()
|
str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
fmt.Println(str)
|
fmt.Println(str)
|
||||||
|
|
||||||
## Set HTTPS
|
## Set HTTPS
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ More info about the `tls.Config` please visit http://golang.org/pkg/crypto/tls/#
|
|||||||
some servers need to specify the protocol version of HTTP
|
some servers need to specify the protocol version of HTTP
|
||||||
|
|
||||||
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
|
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
|
||||||
|
|
||||||
## Set Cookie
|
## Set Cookie
|
||||||
|
|
||||||
some http request need setcookie. So set it like this:
|
some http request need setcookie. So set it like this:
|
||||||
@ -86,8 +87,8 @@ httplib support mutil file upload, use `req.PostFile()`
|
|||||||
req.PostFile("uploadfile1", "httplib.pdf")
|
req.PostFile("uploadfile1", "httplib.pdf")
|
||||||
str, err := req.String()
|
str, err := req.String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
fmt.Println(str)
|
fmt.Println(str)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user