Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthDigest ¶
type AuthDigest struct { // The default algorithm used is DIGEST_SHA256 Algorithm DigestAlgo Realm string URI string QOP string Nonce string CNonce string NC string UserHash bool Opaque string }
AuthDigest is the available Authorization Digest Setting Field Defined under RFC7616-3.4 at https://datatracker.ietf.org/doc/html/rfc7616#section-3.4
func (*AuthDigest) Build ¶
func (d *AuthDigest) Build(user, password string, body *string, method RequestMethods) string
Build is the Digest Access Authentication builder Generate a valid Digest header value in accordance with the RFC7616 But retains backwards compatibility with the RFC2069
Suppose you have filled the information in AuthDigest{}
func (*AuthDigest) Hash ¶
func (d *AuthDigest) Hash(s string) (hashed string)
Hash is the hashing function for Digest Access Authentication AuthDigest can be used with Algorithm - MD5 (RFC2069 and RFC2617) - SHA-256 (RFC7616) - SHA-512-256 (RFC7616) - SHA-512 (for futureproof)
type AuthScheme ¶
type AuthScheme string
const ( AUTH_BASIC AuthScheme = "Basic" AUTH_BEARER AuthScheme = "Bearer" AUTH_DIGEST AuthScheme = "Digest" AUTH_CUSTOM AuthScheme = "Custom" )
type Authorization ¶
type Authorization struct { Scheme AuthScheme Username string Password string // Only for Bearer auth Token string // Only for Digest auth. Digest AuthDigest // The value for Custom auth Value string }
type Client ¶
type Client struct { Settings Settings URL *url.URL Query url.Values Header http.Header Cookie CookieJar Authorization Authorization }
func New ¶
func New(endpoint string, auth ...Authorization) (main Client, err error)
New return an initialized Client struct. This is the main client, you can make request from it or create children for new request with their inheritance
This function require a Endpoint URL with scheme Path. You can also specify a Auth with the optinal Authorization arg
type CookieJar ¶
func (*CookieJar) Add ¶
AddCookie adds the key, value pair to the cookie Jar. It does nothing if the URL's scheme is not HTTP or HTTPS.
func (*CookieJar) Del ¶
Del deletes all cookie entries associated with the given key name in Jar. It does nothing if the URL's scheme is not HTTP or HTTPS.
type DigestAlgo ¶
type DigestAlgo string
DigestAlgo is Hash Algorithms for HTTP Digest Authentication But add SHA512 support to be futureproof Defined under RFC7616-6.1 at https://datatracker.ietf.org/doc/html/rfc7616#section-6.1
const ( DIGEST_MD5 DigestAlgo = "md5" DIGEST_SHA256 DigestAlgo = "sha-256" DIGEST_SHA512 DigestAlgo = "sha-512" DIGEST_SHA512256 DigestAlgo = "sha-512-256" DIGEST_MD5_SESS DigestAlgo = "md5-sess" DIGEST_SHA256_SESS DigestAlgo = "sha-256-sess" DIGEST_SHA512_SESS DigestAlgo = "sha-512-sess" DIGEST_SHA512256_SESS DigestAlgo = "sha-512-256-sess" )
type RequestMethods ¶
type RequestMethods string
const ( METHOD_CONNECT RequestMethods = "CONNECT" METHOD_DELETE RequestMethods = "DELETE" METHOD_GET RequestMethods = "GET" METHOD_HEAD RequestMethods = "HEAD" METHOD_OPTIONS RequestMethods = "OPTIONS" METHOD_PATCH RequestMethods = "PATCH" METHOD_POST RequestMethods = "POST" METHOD_PUT RequestMethods = "PUT" METHOD_TRACE RequestMethods = "TRACE" )
type Settings ¶
type Settings struct { // Follow is for auto follow the HTTP 3xx as redirects (def: true) Follow bool // FollowAuth Keep authorization header when redirect to a different host (def: false) FollowAuth bool // FollowReferer keep the referer header when a redirect happens (def: true) FollowReferer bool // MaxRedirect to set the maximum number of redirects to follow (def: 2) MaxRedirect uint8 // AutoCookie store automatically cookie's if a set-cookie is found in header (def: true) AutoCookie bool // Retry if request is not 2xx or 3xx (def: true) Retry bool // MaxRetry to set the maximum number of retry (def: 1) MaxRetry uint8 // WaitRetry to set the time to wait before retry in second (def: 10) WaitRetry time.Duration }