DoHTTP performs a Request, using OIDC authentication if set.
(req *http.Request)
| 151 | |
| 152 | // DoHTTP performs a Request, using OIDC authentication if set. |
| 153 | func (r *ProtocolIncus) DoHTTP(req *http.Request) (*http.Response, error) { |
| 154 | r.addClientHeaders(req) |
| 155 | |
| 156 | if r.oidcClient != nil { |
| 157 | return r.oidcClient.do(req) |
| 158 | } |
| 159 | |
| 160 | resp, err := r.http.Do(req) |
| 161 | if resp != nil && resp.StatusCode == http.StatusUseProxy && req.GetBody != nil { |
| 162 | // Reset the request body. |
| 163 | body, err := req.GetBody() |
| 164 | if err != nil { |
| 165 | return nil, err |
| 166 | } |
| 167 | |
| 168 | req.Body = body |
| 169 | |
| 170 | // Retry the request. |
| 171 | return r.http.Do(req) |
| 172 | } |
| 173 | |
| 174 | return resp, err |
| 175 | } |
| 176 | |
| 177 | // DoWebsocket performs a websocket connection, using OIDC authentication if set. |
| 178 | func (r *ProtocolIncus) DoWebsocket(dialer websocket.Dialer, uri string, req *http.Request) (*websocket.Conn, *http.Response, error) { |
no test coverage detected