Add SetBasicAuth function for HTTP Auth

This commit is contained in:
smallfish
2014-08-20 23:36:58 +08:00
parent ff9c8d94e6
commit 9a583323a8
2 changed files with 18 additions and 0 deletions

View File

@@ -120,6 +120,18 @@ func TestWithCookie(t *testing.T) {
}
}
func TestWithBasicAuth(t *testing.T) {
str, err := Get("http://httpbin.org/basic-auth/user/passwd").SetBasicAuth("user", "passwd").String()
if err != nil {
t.Fatal(err)
}
t.Log(str)
n := strings.Index(str, "authenticated")
if n == -1 {
t.Fatal("authenticated not found in response")
}
}
func TestWithUserAgent(t *testing.T) {
v := "beego"
str, err := Get("http://httpbin.org/headers").SetUserAgent(v).String()