pub fn curl_text_with_args(
url: &str,
extra_args: &[&str],
) -> Result<String, Box<dyn Error + Send + Sync>>Expand description
What: Fetch plain text from a URL using curl with custom arguments.
Inputs:
url: URL to requestextra_args: Additional curl arguments (e.g.,["--max-time", "10"])
Output:
Ok(String)with response body;Errif curl or UTF-8 decoding fails
§Errors
- Returns
Errwhen curl command execution fails (I/O error or curl not found) - Returns
Errwhen curl exits with non-zero status (network errors, HTTP errors, timeouts) - Returns
Errwhen response body cannot be decoded as UTF-8 - Returns
Errwith message containing “429” when HTTP 429 (Too Many Requests) is received
Details:
- Executes curl with appropriate flags plus extra arguments.
- On Windows, uses
-kflag to skip SSL certificate verification. - Uses
-iflag to include headers for Retry-After parsing. - Uses
-w "\n%{http_code}\n"to detect HTTP status codes, especially 429. - Provides user-friendly error messages for common curl failure cases.
- HTTP 429/503 errors include Retry-After information when available.