From 847434d844c337d8833468a11f9964969bae1b77 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 31 Dec 2020 15:41:15 -0800 Subject: [PATCH] Reorganize some code --- src/main.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7e22049..d3a7fee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -226,17 +226,6 @@ async fn send_response(url: Url, stream: &mut W) -> Result { Ok(()) } -async fn send_header(stream: &mut W, status: u8, meta: &[&str]) -> Result { - use std::fmt::Write; - let mut response = String::with_capacity(64); - write!(response, "{} ", status)?; - response.extend(meta.iter().copied()); - log::info!("Responding with status {:?}", response); - response.push_str("\r\n"); - stream.write_all(response.as_bytes()).await?; - Ok(()) -} - async fn list_directory(stream: &mut W, path: &Path) -> Result { // https://url.spec.whatwg.org/#path-percent-encode-set const ENCODE_SET: AsciiSet = CONTROLS.add(b' ') @@ -269,6 +258,17 @@ async fn list_directory(stream: &mut W, path: &Path) -> Result Ok(()) } +async fn send_header(stream: &mut W, status: u8, meta: &[&str]) -> Result { + use std::fmt::Write; + let mut response = String::with_capacity(64); + write!(response, "{} ", status)?; + response.extend(meta.iter().copied()); + log::info!("Responding with status {:?}", response); + response.push_str("\r\n"); + stream.write_all(response.as_bytes()).await?; + Ok(()) +} + async fn send_text_gemini_header(stream: &mut W) -> Result { if let Some(lang) = ARGS.language.as_deref() { send_header(stream, 20, &["text/gemini;lang=", lang]).await