commit | 9d6d3110b8a8d7450857bebd17b19410ce3ccfe6 | [log] [tgz] |
---|---|---|
author | Dmitriy Panov <dvpanov@avito.ru> | Sun Jun 23 11:42:46 2019 +0300 |
committer | Dmitriy Panov <dvpanov@avito.ru> | Sun Jun 23 11:42:46 2019 +0300 |
tree | 031276b3d2b54d244d7a9deb998273af922fe03f | |
parent | 12e4990b3e13b8390c0595b3b5128ee88d9c6801 [diff] |
small optimization: using strings.Contains instead regexp.MatchString
Golang Http Digest Authentication Client
This client implements RFC7616 HTTP Digest Access Authentication and by now the basic features should work.
// import import dac "github.com/xinsnake/go-http-digest-auth-client" // create a new digest authentication request dr := dac.NewRequest(username, password, method, uri, payload) response1, err := dr.Execute() // check error, get response // reuse the existing digest authentication request so no extra request is needed dr.UpdateRequest(username, password, method, uri, payload) response2, err := dr.Execute() // check error, get response
Or you can use it with http.Request
t := dac.NewTransport(username, password)
req, err := http.NewRequest(method, uri, payload)
if err != nil {
log.Fatalln(err)
}
resp, err := t.RoundTrip(req)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
fmt.Println(resp)