File tree 2 files changed +18
-14
lines changed
2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ type authorizer struct {
33
33
defAuth Authenticator
34
34
}
35
35
36
+ type preemptiveAuthorizer struct {
37
+ auth Authenticator
38
+ }
39
+
36
40
// authShim structure that wraps the real Authenticator
37
41
type authShim struct {
38
42
factory AuthFactory
@@ -66,6 +70,11 @@ func NewEmptyAuth() Authorizer {
66
70
return az
67
71
}
68
72
73
+ // NewPreemptiveAuth creates a preemptive Authenticator
74
+ func NewPreemptiveAuth (auth Authenticator ) Authorizer {
75
+ return & preemptiveAuthorizer {auth }
76
+ }
77
+
69
78
// NewAuthenticator creates an Authenticator (Shim) per request
70
79
func (a * authorizer ) NewAuthenticator (body io.Reader ) (Authenticator , io.Reader ) {
71
80
var retryBuf io.Reader = body
@@ -205,3 +214,11 @@ func (n *nullAuth) Clone() Authenticator {
205
214
func (n * nullAuth ) String () string {
206
215
return "NullAuth"
207
216
}
217
+
218
+ func (b * preemptiveAuthorizer ) NewAuthenticator (body io.Reader ) (Authenticator , io.Reader ) {
219
+ return b .auth .Clone (), body
220
+ }
221
+
222
+ func (b * preemptiveAuthorizer ) AddAuthenticator (key string , fn AuthFactory ) {
223
+ panic ("not implemented" )
224
+ }
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package gowebdav
2
2
3
3
import (
4
4
"fmt"
5
- "io"
6
5
"net/http"
7
6
)
8
7
@@ -46,17 +45,5 @@ func (b *BasicAuth) String() string {
46
45
// no fancy body buffering, no magic at all
47
46
// just dump as if it were on tag 8
48
47
func NewBasicAuth (login , secret string ) Authorizer {
49
- return & basicAuthAuthorizer {& BasicAuth {login , secret }}
50
- }
51
-
52
- type basicAuthAuthorizer struct {
53
- auth * BasicAuth
54
- }
55
-
56
- func (b * basicAuthAuthorizer ) NewAuthenticator (body io.Reader ) (Authenticator , io.Reader ) {
57
- return b .auth , body
58
- }
59
-
60
- func (b * basicAuthAuthorizer ) AddAuthenticator (key string , fn AuthFactory ) {
61
- panic ("not implemented" )
48
+ return & preemptiveAuthorizer {& BasicAuth {login , secret }}
62
49
}
You can’t perform that action at this time.
0 commit comments