@@ -113,15 +113,15 @@ func (a *Agent) WithRetries(retries uint) *Agent {
113
113
}
114
114
115
115
// WithWaitTime sets the initial wait time for request retry.
116
- func (a * Agent ) WithWaitTime (time time.Duration ) * Agent {
117
- a .options .WaitTime = time
116
+ func (a * Agent ) WithWaitTime (t time.Duration ) * Agent {
117
+ a .options .WaitTime = t
118
118
119
119
return a
120
120
}
121
121
122
122
// WithMaxWaitTime sets the maximum wait time for request retry.
123
- func (a * Agent ) WithMaxWaitTime (time time.Duration ) * Agent {
124
- a .options .MaxWaitTime = time
123
+ func (a * Agent ) WithMaxWaitTime (t time.Duration ) * Agent {
124
+ a .options .MaxWaitTime = t
125
125
126
126
return a
127
127
}
@@ -149,8 +149,8 @@ func (a *Agent) Client() *http.Client {
149
149
}
150
150
151
151
// Get returns the body a GET request.
152
- func (a * Agent ) Get (url string ) (content []byte , err error ) {
153
- request , err := a .GetRequest (url )
152
+ func (a * Agent ) Get (u string ) (content []byte , err error ) {
153
+ request , err := a .GetRequest (u )
154
154
if err != nil {
155
155
return nil , fmt .Errorf ("getting GET request: %w" , err )
156
156
}
@@ -160,17 +160,17 @@ func (a *Agent) Get(url string) (content []byte, err error) {
160
160
}
161
161
162
162
// GetRequest sends a GET request to a URL and returns the request and response.
163
- func (a * Agent ) GetRequest (url string ) (response * http.Response , err error ) {
164
- logrus .Debugf ("Sending GET request to %s" , url )
163
+ func (a * Agent ) GetRequest (u string ) (response * http.Response , err error ) {
164
+ logrus .Debugf ("Sending GET request to %s" , u )
165
165
166
166
return a .retryRequest (func () (* http.Response , error ) {
167
- return a .SendGetRequest (a .Client (), url )
167
+ return a .SendGetRequest (a .Client (), u )
168
168
})
169
169
}
170
170
171
171
// Post returns the body of a POST request.
172
- func (a * Agent ) Post (url string , postData []byte ) (content []byte , err error ) {
173
- response , err := a .PostRequest (url , postData )
172
+ func (a * Agent ) Post (u string , postData []byte ) (content []byte , err error ) {
173
+ response , err := a .PostRequest (u , postData )
174
174
if err != nil {
175
175
return nil , fmt .Errorf ("getting post request: %w" , err )
176
176
}
@@ -180,11 +180,11 @@ func (a *Agent) Post(url string, postData []byte) (content []byte, err error) {
180
180
}
181
181
182
182
// PostRequest sends the postData in a POST request to a URL and returns the request object.
183
- func (a * Agent ) PostRequest (url string , postData []byte ) (response * http.Response , err error ) {
184
- logrus .Debugf ("Sending POST request to %s" , url )
183
+ func (a * Agent ) PostRequest (u string , postData []byte ) (response * http.Response , err error ) {
184
+ logrus .Debugf ("Sending POST request to %s" , u )
185
185
186
186
return a .retryRequest (func () (* http.Response , error ) {
187
- return a .SendPostRequest (a .Client (), url , postData , a .options .PostContentType )
187
+ return a .SendPostRequest (a .Client (), u , postData , a .options .PostContentType )
188
188
})
189
189
}
190
190
@@ -226,8 +226,8 @@ func shouldRetry(resp *http.Response, err error) error {
226
226
}
227
227
228
228
// Head returns the body of a HEAD request.
229
- func (a * Agent ) Head (url string ) (content []byte , err error ) {
230
- response , err := a .HeadRequest (url )
229
+ func (a * Agent ) Head (u string ) (content []byte , err error ) {
230
+ response , err := a .HeadRequest (u )
231
231
if err != nil {
232
232
return nil , fmt .Errorf ("getting head request: %w" , err )
233
233
}
@@ -237,13 +237,13 @@ func (a *Agent) Head(url string) (content []byte, err error) {
237
237
}
238
238
239
239
// HeadRequest sends a HEAD request to a URL and returns the request and response.
240
- func (a * Agent ) HeadRequest (url string ) (response * http.Response , err error ) {
241
- logrus .Debugf ("Sending HEAD request to %s" , url )
240
+ func (a * Agent ) HeadRequest (u string ) (response * http.Response , err error ) {
241
+ logrus .Debugf ("Sending HEAD request to %s" , u )
242
242
243
243
var try uint
244
244
245
245
for {
246
- response , err = a .SendHeadRequest (a .Client (), url )
246
+ response , err = a .SendHeadRequest (a .Client (), u )
247
247
try ++
248
248
249
249
if err == nil || try >= a .options .Retries {
@@ -266,39 +266,39 @@ func (a *Agent) HeadRequest(url string) (response *http.Response, err error) {
266
266
267
267
// SendPostRequest sends the actual HTTP post to the server.
268
268
func (impl * defaultAgentImplementation ) SendPostRequest (
269
- client * http.Client , url string , postData []byte , contentType string ,
269
+ client * http.Client , u string , postData []byte , contentType string ,
270
270
) (response * http.Response , err error ) {
271
271
if contentType == "" {
272
272
contentType = defaultPostContentType
273
273
}
274
274
275
- response , err = client .Post (url , contentType , bytes .NewBuffer (postData ))
275
+ response , err = client .Post (u , contentType , bytes .NewBuffer (postData ))
276
276
if err != nil {
277
- return response , fmt .Errorf ("posting data to %s: %w" , url , err )
277
+ return response , fmt .Errorf ("posting data to %s: %w" , u , err )
278
278
}
279
279
280
280
return response , nil
281
281
}
282
282
283
283
// SendGetRequest performs the actual request.
284
- func (impl * defaultAgentImplementation ) SendGetRequest (client * http.Client , url string ) (
284
+ func (impl * defaultAgentImplementation ) SendGetRequest (client * http.Client , u string ) (
285
285
response * http.Response , err error ,
286
286
) {
287
- response , err = client .Get (url )
287
+ response , err = client .Get (u )
288
288
if err != nil {
289
- return response , fmt .Errorf ("getting %s: %w" , url , err )
289
+ return response , fmt .Errorf ("getting %s: %w" , u , err )
290
290
}
291
291
292
292
return response , nil
293
293
}
294
294
295
295
// SendHeadRequest performs the actual request.
296
- func (impl * defaultAgentImplementation ) SendHeadRequest (client * http.Client , url string ) (
296
+ func (impl * defaultAgentImplementation ) SendHeadRequest (client * http.Client , u string ) (
297
297
response * http.Response , err error ,
298
298
) {
299
- response , err = client .Head (url )
299
+ response , err = client .Head (u )
300
300
if err != nil {
301
- return response , fmt .Errorf ("sending head request %s: %w" , url , err )
301
+ return response , fmt .Errorf ("sending head request %s: %w" , u , err )
302
302
}
303
303
304
304
return response , nil
@@ -342,8 +342,8 @@ func (a *Agent) readResponse(response *http.Response, w io.Writer) (err error) {
342
342
}
343
343
344
344
// GetToWriter sends a get request and writes the response to an io.Writer.
345
- func (a * Agent ) GetToWriter (w io.Writer , url string ) error {
346
- resp , err := a .SendGetRequest (a .Client (), url )
345
+ func (a * Agent ) GetToWriter (w io.Writer , u string ) error {
346
+ resp , err := a .SendGetRequest (a .Client (), u )
347
347
if err != nil {
348
348
return fmt .Errorf ("sending GET request: %w" , err )
349
349
}
@@ -352,8 +352,8 @@ func (a *Agent) GetToWriter(w io.Writer, url string) error {
352
352
}
353
353
354
354
// PostToWriter sends a request to a url and writes the response to an io.Writer.
355
- func (a * Agent ) PostToWriter (w io.Writer , url string , postData []byte ) error {
356
- resp , err := a .SendPostRequest (a .Client (), url , postData , a .options .PostContentType )
355
+ func (a * Agent ) PostToWriter (w io.Writer , u string , postData []byte ) error {
356
+ resp , err := a .SendPostRequest (a .Client (), u , postData , a .options .PostContentType )
357
357
if err != nil {
358
358
return fmt .Errorf ("sending POST request: %w" , err )
359
359
}
0 commit comments