Debian Codegraph @

transport.go

raw
1 package spnego
2
3 import "net/http"
4
5 // Transport extends the native http.Transport to provide SPNEGO communication
6 type Transport struct {
7 http.Transport
8 spnego Provider
9 }
10
11 // Error is used to distinguish errors from underlying libraries (gokrb5 or sspi).
12 type Error struct {
13 Err error
14 }
15
16 // Error implements the error interface
17 func (e *Error) Error() string {
18 return e.Err.Error()
19 }
20
21 // RoundTrip implements the RoundTripper interface.
22 func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
23 if t.spnego == nil {
24 t.spnego = New()
25 }
26
27 if err := t.spnego.SetSPNEGOHeader(req); err != nil {
28 return nil, &Error{Err: err}
29 }
30
31 return t.Transport.RoundTrip(req)
32 // ToDo: process negotiate token from response
33 }