digest_auth_client

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2018 License: BSD-2-Clause Imports: 12 Imported by: 7

README

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

// 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)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DigestRequest

type DigestRequest struct {
	Body     string
	Method   string
	Password string
	Uri      string
	Username string
	Header   http.Header
	Auth     *authorization
	Wa       *wwwAuthenticate
}

func NewRequest

func NewRequest(username, password, method, uri, body string, header http.Header) DigestRequest

NewRequest creates a new DigestRequest object

func (*DigestRequest) Execute

func (dr *DigestRequest) Execute() (resp *http.Response, err error)

Execute initialise the request and get a response

func (*DigestRequest) UpdateRequest

func (dr *DigestRequest) UpdateRequest(username, password, method, uri, body string, header http.Header) *DigestRequest

UpdateRequest is called when you want to reuse an existing

DigestRequest connection with new request information

type DigestTransport added in v0.2.0

type DigestTransport struct {
	Password string
	Username string
}

func NewTransport added in v0.2.0

func NewTransport(username, password string) DigestTransport

NewTransport creates a new DigestTransport object

func (*DigestTransport) RoundTrip added in v0.2.0

func (dt *DigestTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip implements the http.RoundTripper interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL