don't die on utf8 errors

pull/14/head
dvkt 4 years ago
parent 81ead3ab7f
commit 7905daf869

@ -100,7 +100,6 @@ You can check whether TLS is enabled by visiting the About page:
## bugs
- [ ] "stream did not contain valid UTF-8" sdf.org/maps/
- [ ] ctrl-z (suspend) doesn't work
- [ ] unknown keypress: \n needs escaping
- [ ] unknown keypress: [ during status messages

@ -60,9 +60,9 @@ pub fn fetch_url(url: &str, try_tls: bool) -> Result<(bool, String)> {
/// (did tls work?, raw Gopher response)
pub fn fetch(host: &str, port: &str, selector: &str, try_tls: bool) -> Result<(bool, String)> {
let mut stream = request(host, port, selector, try_tls)?;
let mut body = String::new();
stream.read_to_string(&mut body)?;
Ok((stream.is_tls(), body))
let mut body = Vec::new();
stream.read_to_end(&mut body)?;
Ok((stream.is_tls(), String::from_utf8_lossy(&body).into()))
}
/// Downloads a binary to disk. Allows canceling with Ctrl-c.

Loading…
Cancel
Save