This commit is contained in:
shoopea 2024-01-20 11:27:24 +01:00
parent 42ddb5a83e
commit d59e787694

View File

@ -2,6 +2,7 @@ package gowebdav
import ( import (
"fmt" "fmt"
"log"
"net/http" "net/http"
) )
@ -14,11 +15,13 @@ type BasicAuth struct {
// Authorize the current request // Authorize the current request
func (b *BasicAuth) Authorize(c *http.Client, rq *http.Request, path string) error { func (b *BasicAuth) Authorize(c *http.Client, rq *http.Request, path string) error {
rq.SetBasicAuth(b.user, b.pw) rq.SetBasicAuth(b.user, b.pw)
log.Printf("BasicAuth.Authorize : SetBasicAuth(%s, %s)", b.user, b.pw)
return nil return nil
} }
// Verify verifies if the authentication // Verify verifies if the authentication
func (b *BasicAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) { func (b *BasicAuth) Verify(c *http.Client, rs *http.Response, path string) (redo bool, err error) {
log.Printf("BasicAuth.Verify : StatusCode = %d", rs.StatusCode)
if rs.StatusCode == 401 { if rs.StatusCode == 401 {
err = NewPathError("Authorize", path, rs.StatusCode) err = NewPathError("Authorize", path, rs.StatusCode)
} }
@ -27,16 +30,19 @@ func (b *BasicAuth) Verify(c *http.Client, rs *http.Response, path string) (redo
// Close cleans up all resources // Close cleans up all resources
func (b *BasicAuth) Close() error { func (b *BasicAuth) Close() error {
log.Printf("BasicAuth.Close")
return nil return nil
} }
// Clone creates a Copy of itself // Clone creates a Copy of itself
func (b *BasicAuth) Clone() Authenticator { func (b *BasicAuth) Clone() Authenticator {
log.Printf("BasicAuth.Clone")
// no copy due to read only access // no copy due to read only access
return b return b
} }
// String toString // String toString
func (b *BasicAuth) String() string { func (b *BasicAuth) String() string {
log.Printf("BasicAuth.String")
return fmt.Sprintf("BasicAuth login: %s", b.user) return fmt.Sprintf("BasicAuth login: %s", b.user)
} }