@@ -132,6 +132,12 @@ var applicationJSON = "application/json"
132132// Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication
133133// header will automatically be provided.
134134func (client * ProviderClient ) Request (method , url string , options RequestOpts ) (* http.Response , error ) {
135+ return client .request (method , url , options , false )
136+ }
137+
138+ // Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication
139+ // header will automatically be provided.
140+ func (client * ProviderClient ) request (method , url string , options RequestOpts , recursionFlag bool ) (* http.Response , error ) {
135141 var body io.ReadSeeker
136142 var contentType * string
137143
@@ -187,14 +193,17 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) (
187193
188194 // Set connection parameter to close the connection immediately when we've got the response
189195 req .Close = true
190-
196+
191197 // Issue the request.
192198 resp , err := client .HTTPClient .Do (req )
193199 if err != nil {
194200 return nil , err
195201 }
196202
197203 if resp .StatusCode == http .StatusUnauthorized {
204+ if recursionFlag {
205+ return nil , fmt .Errorf ("Successfully re-authenticated, but got error executing request: %s" , err )
206+ }
198207 if client .ReauthFunc != nil {
199208 err = client .ReauthFunc ()
200209 if err != nil {
@@ -204,7 +213,7 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) (
204213 options .RawBody .Seek (0 , 0 )
205214 }
206215 resp .Body .Close ()
207- resp , err = client .Request (method , url , options )
216+ resp , err = client .request (method , url , options , true )
208217 if err != nil {
209218 return nil , fmt .Errorf ("Successfully re-authenticated, but got error executing request: %s" , err )
210219 }
0 commit comments