I find myself in need to handle various authentication schemes such 
"proprietary" oauth2 schemes and NTLM. The easy and clean way to do it (API 
wise) would be using a http.RoundTripper but looks like it forbids you from 
even reading the response headers.

 In the end I just made a ``func DoHTTPRequestWithAuthenticationHandling(cl 
*http.Client, req *http.Request)(*http.Response, error)`` function that 
just wraps  net/http.Client.Do(), clones the request and response if it's 
necessary and negotiates the authentication scheme. It's basically what I 
wanted to do within http.RoundTripper except now the user of the 
http.Client needs to always remember to execute the requests the right way 
(i.e. using a different function) instead of http.Do.

Is there a better way to do it? Would it be a good idea  in Go 2.0  make 
http.Client an interface to prevent this kind of limitation/workarounds?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f6ecfd34-a5b9-4b83-a56d-bcbf6b47086fn%40googlegroups.com.

Reply via email to