digest_auth_client

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: BSD-2-Clause Imports: 13 Imported by: 4 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	CertVal    bool
	HTTPClient *http.Client
}

func NewRequest

func NewRequest(username, password, method, uri, body string) 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) *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
	HTTPClient *http.Client
}

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
⌂ 换网址