1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-18 11:24:14 +00:00

Update README

This commit is contained in:
陈小玉 2014-08-21 00:08:08 +08:00
parent e70537f8b3
commit 6ae8bc1a16

View File

@ -10,8 +10,8 @@ you can use Get to crawl data.
str, err := httplib.Get("http://beego.me/").String()
if err != nil {
// error
}
// error
}
fmt.Println(str)
## POST
@ -22,8 +22,8 @@ POST data to remote url
req.Param("password","123456")
str, err := req.String()
if err != nil {
// error
}
// error
}
fmt.Println(str)
## Set timeout
@ -32,7 +32,8 @@ The default timeout is `60` seconds, function prototype:
SetTimeout(connectTimeout, readWriteTimeout time.Duration)
Exmaple:
Exmaple:
// GET
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
str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String()
if err != nil {
// error
}
fmt.Println(str)
if err != nil {
// error
}
fmt.Println(str)
## 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
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
## Set Cookie
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")
str, err := req.String()
if err != nil {
// error
}
// error
}
fmt.Println(str)