pub fn curl_text_with_args_headers(
url: &str,
extra_args: &[&str],
) -> Result<CurlResponse, Box<dyn Error + Send + Sync>>Expand description
What: Fetch plain text from a URL using curl with custom arguments, including headers.
Inputs:
url: URL to requestextra_args: Additional curl arguments (e.g.,["--max-time", "10"])
Output:
Ok(CurlResponse)with response body, status code, and parsed headers;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
Details:
- Executes curl with
-iflag to include headers in output. - Uses
-w "\n%{http_code}\n"to get HTTP status code at the end. - Parses Retry-After header from response headers.
- Separates headers from body in the response.