9cc2e723 by astaxie

add httplib readme

1 parent 63b82c43
1 # httplib
2 httplib is an libs help you to curl remote url.
3
4 # How to use?
5
6 ## GET
7 you can use Get to crawl data.
8
9 import "httplib"
10
11 str, err := httplib.Get("http://beego.me/").String()
12 if err != nil {
13 t.Fatal(err)
14 }
15 fmt.Println(str)
16
17 ## POST
18 POST data to remote url
19
20 b:=httplib.Post("http://beego.me/")
21 b.Param("username","astaxie")
22 b.Param("password","123456")
23 str, err := b.String()
24 if err != nil {
25 t.Fatal(err)
26 }
27 fmt.Println(str)
28
29 ## set timeout
30 you can set timeout in request.default is 60 seconds.
31
32 set Get timeout:
33
34 httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
35
36 set post timeout:
37
38 httplib.Post("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
39
40 - first param is connectTimeout.
41 - second param is readWriteTimeout
42
43 ## debug
44 if you want to debug the request info, set the debug on
45
46 httplib.Get("").Debug(true)
...\ No newline at end of file ...\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!