curl_text

Function curl_text 

Source
pub fn curl_text(url: &str) -> Result<String, Box<dyn Error + Send + Sync>>
Expand description

What: Fetch plain text from a URL using curl.

Inputs:

  • url: URL to request

Output:

  • Ok(String) with response body; Err if curl or UTF-8 decoding fails

ยงErrors

  • Returns Err when curl command execution fails (I/O error or curl not found)
  • Returns Err when curl exits with non-zero status (network errors, HTTP errors, timeouts)
  • Returns Err when response body cannot be decoded as UTF-8

Details:

  • Executes curl with appropriate flags and returns the raw body as a String.
  • On Windows, uses -k flag to skip SSL certificate verification.
  • Provides user-friendly error messages for common curl failure cases.