/// Turn this response into a String of the response body. By default uses `utf-8`,
/// but can work with charset, see below.
///
/// This is potentially memory inefficient for large bodies since the
/// implementation first reads the reader to end into a `Vec<u8>` and then
/// attempts to decode it using the charset.
///
/// If the response is larger than 10 megabytes, this will return an error.
///
/// Example:
///
/// ```
/// # fn main() -> Result<(), ureq::Error> {
/// # ureq::is_test(true);
/// let text = ureq::get("http://httpbin.org/get/success")
///     .call()?
///     .into_string()?;
///
/// assert!(text.contains("success"));
/// # Ok(())
/// # }
/// ```
///
/// ## Charset support
///
/// If you enable feature `ureq = { version = "*", features = ["charset"] }`, into_string()
/// attempts to respect the character encoding of the `Content-Type` header. If there is no
/// Content-Type header, or the Content-Type header does not specify a charset, into_string()
/// uses `utf-8`.
///
/// I.e. `Content-Length: text/plain; charset=iso-8859-1` would be decoded in latin-1.
///
Turn this response into a String of the response body. By default uses `utf-8`,
but can work with charset, see below.

This is potentially memory inefficient for large bodies since the
implementation first reads the reader to end into a `Vec` and then
attempts to decode it using the charset.

If the response is larger than 10 megabytes, this will return an error.




Turn this response into a String of the response body . By default uses ` utf - 8 ` but can work with charset see below . This is potentially memory inefficient for large bodies since the implementation first reads the reader to end into a ` Vec ` and then attempts to decode it using the charset . If the response is larger than 10 megabytes this will return an error .
pub fn into_string(self) -> io::Result<String> {
        #[cfg(feature = "charset")]
        let encoding = Encoding::for_label(self.charset().as_bytes())
            .or_else(|| Encoding::for_label(DEFAULT_CHARACTER_SET.as_bytes()))
            .unwrap();
        let mut buf: Vec<u8> = vec![];
        self.into_reader()
            .take((INTO_STRING_LIMIT + 1) as u64)
            .read_to_end(&mut buf)?;
        if buf.len() > INTO_STRING_LIMIT {
            return Err(io::Error::new(
                    io::ErrorKind::Other,
                    "response too big for into_string",
                    ));
        }
        #[cfg(feature = "charset")]
        {
            let (text, _, _) = encoding.decode(&buf);
            Ok(text.into_owned())
        }
        #[cfg(not(feature = "charset"))]
        {
            Ok(String::from_utf8_lossy(&buf).to_string())
        }
    }
pub fn into_string ( self ) -> io :: Result < String > { # [ cfg ( feature " " ) ] let encoding = Encoding :: for_label ( self . charset ( ) . as_bytes ( ) ) . or_else ( | | Encoding :: for_label ( DEFAULT_CHARACTER_SET . as_bytes ( ) ) ) . unwrap ( ) ; let mut buf : Vec < u8 > = vec ! [ ] ; self . into_reader ( ) . take ( ( INTO_STRING_LIMIT + 1 ) as u64 ) . read_to_end ( & mut buf ) ? ; if buf . len ( ) > INTO_STRING_LIMIT { return Err ( io :: Error :: new ( io :: ErrorKind :: Other , " " , ) ) ; } # [ cfg ( feature " " ) ] { let ( text , _ , _ ) = encoding . decode ( & buf ) ; Ok ( text . into_owned ( ) ) } # [ cfg ( not ( feature " " ) ) ] { Ok ( String :: from_utf8_lossy ( & buf ) . to_string ( ) ) } }
Turn this response into a String of the response body.
Turn this response into a String of the response body .
self
fn main() -> result<(), ureq::error> {
None
ureq::is_test(true);
None
ok(())
None
}
None
charset support
If you enable feature `ureq = { version = "*", features = ["charset"] }`, into_string()
attempts to respect the character encoding of the `Content-Type` header. If there is no
Content-Type header, or the Content-Type header does not specify a charset, into_string()
uses `utf-8`.

I.e. `Content-Length: text/plain; charset=iso-8859-1` would be decoded in latin-1.
If you enable feature ` ureq = { version = " * " features = [ " charset " ] } ` into_string () attempts to respect the character encoding of the ` Content - Type ` header . If there is no Content - Type header or the Content - Type header does not specify a charset into_string () uses ` utf - 8 ` . I . e . ` Content - Length : text / plain ; charset = iso - 8859 - 1 ` would be decoded in latin - 1 .