Update README
Showing
1 changed file
with
13 additions
and
12 deletions
| ... | @@ -10,8 +10,8 @@ you can use Get to crawl data. | ... | @@ -10,8 +10,8 @@ you can use Get to crawl data. |
| 10 | 10 | ||
| 11 | str, err := httplib.Get("http://beego.me/").String() | 11 | str, err := httplib.Get("http://beego.me/").String() |
| 12 | if err != nil { | 12 | if err != nil { |
| 13 | // error | 13 | // error |
| 14 | } | 14 | } |
| 15 | fmt.Println(str) | 15 | fmt.Println(str) |
| 16 | 16 | ||
| 17 | ## POST | 17 | ## POST |
| ... | @@ -22,8 +22,8 @@ POST data to remote url | ... | @@ -22,8 +22,8 @@ POST data to remote url |
| 22 | req.Param("password","123456") | 22 | req.Param("password","123456") |
| 23 | str, err := req.String() | 23 | str, err := req.String() |
| 24 | if err != nil { | 24 | if err != nil { |
| 25 | // error | 25 | // error |
| 26 | } | 26 | } |
| 27 | fmt.Println(str) | 27 | fmt.Println(str) |
| 28 | 28 | ||
| 29 | ## Set timeout | 29 | ## Set timeout |
| ... | @@ -32,7 +32,8 @@ The default timeout is `60` seconds, function prototype: | ... | @@ -32,7 +32,8 @@ The default timeout is `60` seconds, function prototype: |
| 32 | 32 | ||
| 33 | SetTimeout(connectTimeout, readWriteTimeout time.Duration) | 33 | SetTimeout(connectTimeout, readWriteTimeout time.Duration) |
| 34 | 34 | ||
| 35 | Exmaple: | 35 | Exmaple: |
| 36 | |||
| 36 | // GET | 37 | // GET |
| 37 | httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second) | 38 | httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second) |
| 38 | 39 | ||
| ... | @@ -49,10 +50,10 @@ If you want to debug the request info, set the debug on | ... | @@ -49,10 +50,10 @@ If you want to debug the request info, set the debug on |
| 49 | ## Set HTTP Basic Auth | 50 | ## Set HTTP Basic Auth |
| 50 | 51 | ||
| 51 | str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String() | 52 | str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String() |
| 52 | if err != nil { | 53 | if err != nil { |
| 53 | // error | 54 | // error |
| 54 | } | 55 | } |
| 55 | fmt.Println(str) | 56 | fmt.Println(str) |
| 56 | 57 | ||
| 57 | ## Set HTTPS | 58 | ## Set HTTPS |
| 58 | 59 | ||
| ... | @@ -67,7 +68,7 @@ More info about the `tls.Config` please visit http://golang.org/pkg/crypto/tls/# | ... | @@ -67,7 +68,7 @@ More info about the `tls.Config` please visit http://golang.org/pkg/crypto/tls/# |
| 67 | some servers need to specify the protocol version of HTTP | 68 | some servers need to specify the protocol version of HTTP |
| 68 | 69 | ||
| 69 | httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1") | 70 | httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1") |
| 70 | 71 | ||
| 71 | ## Set Cookie | 72 | ## Set Cookie |
| 72 | 73 | ||
| 73 | some http request need setcookie. So set it like this: | 74 | some http request need setcookie. So set it like this: |
| ... | @@ -86,8 +87,8 @@ httplib support mutil file upload, use `req.PostFile()` | ... | @@ -86,8 +87,8 @@ httplib support mutil file upload, use `req.PostFile()` |
| 86 | req.PostFile("uploadfile1", "httplib.pdf") | 87 | req.PostFile("uploadfile1", "httplib.pdf") |
| 87 | str, err := req.String() | 88 | str, err := req.String() |
| 88 | if err != nil { | 89 | if err != nil { |
| 89 | // error | 90 | // error |
| 90 | } | 91 | } |
| 91 | fmt.Println(str) | 92 | fmt.Println(str) |
| 92 | 93 | ||
| 93 | 94 | ... | ... |
-
Please register or sign in to post a comment