Thanks for your help. I'm aware I can set the headers that way but the authentication transport also needs to inspect the response headers and optionally re-submit the request based on the headers received. That's part of the "negotiation" mechanism. That's because we don;t know what authentication scheme is supported by the remote party until we receive the actual response/headers from a blind request.
Below is a simple use case:
- the http client executes a reques with no authentication.
- we receive a status code 403 along with a www-header indicating that oauth2 authentication is supported.
- we resend the request with appropriate oauth2 headers.
Note that we had to read the response code and response headers so that we can re-send the request. This is the part that I wish I could automate using the http.RoundTripper.
The alternative is to either handle the response manually after each request or create a custom endpoint < i.e. func ExecuteHTTP(*http.Client, *http.Request)(*http.Response, error) > that handles the response headers and retries the requests using the proper authentication headers.
In both cases you loose the flexibility to use a http client that does all this in the background.
Some packages (i.e ElasticSearch package) support configuration using your own http client. However you cannot pass a custom `ExecuteHTTP` function to ElasticSearch so it becomes quite hard to hack the authentication/negotiation.
- Mihai.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/nTQ7F4b_wvI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a9a6f788-6a45-49cf-9381-4abb98888864n%40googlegroups.com.