httplib:support file upload

This commit is contained in:
astaxie
2014-05-08 16:58:08 +08:00
parent dce09837b9
commit 14688f240f
3 changed files with 69 additions and 7 deletions

View File

@@ -60,3 +60,16 @@ some http request need setcookie. So set it like this:
cookie.Value = "astaxie"
httplib.Get("http://beego.me/").SetCookie(cookie)
## upload file
httplib support mutil file upload, use `b.PostFile()`
b:=httplib.Post("http://beego.me/")
b.Param("username","astaxie")
b.Param("password","123456")
b.PostFile("uploadfile1", "httplib.pdf")
b.PostFile("uploadfile2", "httplib.txt")
str, err := b.String()
if err != nil {
t.Fatal(err)
}
fmt.Println(str)