@@ -132,6 +132,12 @@ var applicationJSON = "application/json"
132
132
// Request performs an HTTP request using the ProviderClient's current HTTPClient. An authentication
133
133
// header will automatically be provided.
134
134
func (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 ) {
135
141
var body io.ReadSeeker
136
142
var contentType * string
137
143
@@ -187,14 +193,17 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) (
187
193
188
194
// Set connection parameter to close the connection immediately when we've got the response
189
195
req .Close = true
190
-
196
+
191
197
// Issue the request.
192
198
resp , err := client .HTTPClient .Do (req )
193
199
if err != nil {
194
200
return nil , err
195
201
}
196
202
197
203
if resp .StatusCode == http .StatusUnauthorized {
204
+ if recursionFlag {
205
+ return nil , fmt .Errorf ("Successfully re-authenticated, but got error executing request: %s" , err )
206
+ }
198
207
if client .ReauthFunc != nil {
199
208
err = client .ReauthFunc ()
200
209
if err != nil {
@@ -204,7 +213,7 @@ func (client *ProviderClient) Request(method, url string, options RequestOpts) (
204
213
options .RawBody .Seek (0 , 0 )
205
214
}
206
215
resp .Body .Close ()
207
- resp , err = client .Request (method , url , options )
216
+ resp , err = client .request (method , url , options , true )
208
217
if err != nil {
209
218
return nil , fmt .Errorf ("Successfully re-authenticated, but got error executing request: %s" , err )
210
219
}
0 commit comments