pull/6/head
dvkt 5 years ago
parent de886e44b3
commit 6006c0019e

@ -137,17 +137,12 @@ pub fn fetch_url(url: &str) -> Result<String> {
// Fetches a gopher URL by its component parts and returns a raw Gopher response.
pub fn fetch(host: &str, port: &str, selector: &str) -> Result<String> {
get(host, port, selector)
.and_then(|mut stream| {
stream.write(format!("{}\r\n", selector).as_ref());
Ok(stream)
})
.and_then(|mut stream| {
let mut body = String::new();
stream.set_read_timeout(Some(TCP_TIMEOUT_DURATION));
stream.read_to_string(&mut body)?;
Ok(body)
})
get(host, port, selector).and_then(|mut stream| {
let mut body = String::new();
stream.set_read_timeout(Some(TCP_TIMEOUT_DURATION));
stream.read_to_string(&mut body)?;
Ok(body)
})
}
// Downloads a binary to disk.

Loading…
Cancel
Save