@@ -367,14 +367,32 @@ const char *rd_http_req_get_content_type(rd_http_req_t *hreq) {
367
367
368
368
/**
369
369
* @brief Perform a blocking HTTP(S) request to \p url.
370
+ * Retries the request \p retries times with linear backoff.
371
+ * Interval of \p retry_ms milliseconds is used between retries.
370
372
*
371
- * Returns the response (even if there's a HTTP error code returned)
372
- * in \p *rbufp.
373
+ * @param url The URL to perform the request to.
374
+ * @param headers_array Array of HTTP(S) headers to set, each element
375
+ * is a string in the form "key: value"
376
+ * @param headers_array_cnt Number of elements in \p headers_array.
377
+ * @param timeout_s Timeout in seconds for the request, 0 means default
378
+ * `rd_http_req_init()` timeout.
379
+ * @param retries Number of retries to perform on failure.
380
+ * @param retry_ms Milliseconds to wait between retries.
381
+ * @param rbufp (out) Pointer to a buffer that will be filled with the response.
382
+ * @param content_type (out, optional) Pointer to a string that will be filled
383
+ * with the content type of the response, if not NULL.
384
+ * @param response_code (out, optional) Pointer to an integer that will be
385
+ * filled with the HTTP response code, if not NULL.
373
386
*
374
- * Returns NULL on success (HTTP response code < 400), or an error
375
- * object on transport or HTTP error - this error object must be destroyed
376
- * by calling rd_http_error_destroy(). In case of HTTP error the \p *rbufp
377
- * may be filled with the error response.
387
+ * @return Returns NULL on success (HTTP response code < 400), or an error
388
+ * object on transport or HTTP error.
389
+ *
390
+ * @remark Returned error object, when non-NULL, must be destroyed
391
+ * by calling rd_http_error_destroy().
392
+ *
393
+ * @locality Any thread.
394
+ * @locks None.
395
+ * @locks_acquired None.
378
396
*/
379
397
rd_http_error_t * rd_http_get (rd_kafka_t * rk ,
380
398
const char * url ,
@@ -409,6 +427,8 @@ rd_http_error_t *rd_http_get(rd_kafka_t *rk,
409
427
headers = curl_slist_append (headers , header );
410
428
}
411
429
curl_easy_setopt (hreq .hreq_curl , CURLOPT_HTTPHEADER , headers );
430
+ if (timeout_s > 0 )
431
+ curl_easy_setopt (hreq .hreq_curl , CURLOPT_TIMEOUT , timeout_s );
412
432
413
433
for (i = 0 ; i <= retries ; i ++ ) {
414
434
if (rd_kafka_terminating (rk )) {
0 commit comments