项目作者: xinsnake

项目描述 :
Golang Http Digest Authentication Client
高级语言: Go
项目地址: git://github.com/xinsnake/go-http-digest-auth-client.git
创建时间: 2016-08-24T00:34:08Z
项目社区:https://github.com/xinsnake/go-http-digest-auth-client

开源协议:BSD 2-Clause "Simplified" License

下载


go-http-digest-auth-client

Golang Http Digest Authentication Client

This client implements RFC7616 HTTP Digest Access Authentication
and by now the basic features should work.

Usage

  1. // import
  2. import dac "github.com/xinsnake/go-http-digest-auth-client"
  3. // create a new digest authentication request
  4. dr := dac.NewRequest(username, password, method, uri, payload)
  5. response1, err := dr.Execute()
  6. // check error, get response
  7. // reuse the existing digest authentication request so no extra request is needed
  8. dr.UpdateRequest(username, password, method, uri, payload)
  9. response2, err := dr.Execute()
  10. // check error, get response

Or you can use it with http.Request

  1. t := dac.NewTransport(username, password)
  2. req, err := http.NewRequest(method, uri, payload)
  3. if err != nil {
  4. log.Fatalln(err)
  5. }
  6. resp, err := t.RoundTrip(req)
  7. if err != nil {
  8. log.Fatalln(err)
  9. }
  10. defer resp.Body.Close()
  11. fmt.Println(resp)