commit 847434d844c337d8833468a11f9964969bae1b77
parent 879422c2ccc2b1a9821c1598d68a540426501f74
Author: Matt Brubeck <mbrubeck@limpet.net>
Date: Thu, 31 Dec 2020 15:41:15 -0800
Reorganize some code
Diffstat:
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -226,17 +226,6 @@ async fn send_response<W: Write + Unpin>(url: Url, stream: &mut W) -> Result {
Ok(())
}
-async fn send_header<W: Write + Unpin>(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<W: Write + Unpin>(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<W: Write + Unpin>(stream: &mut W, path: &Path) -> Result
Ok(())
}
+async fn send_header<W: Write + Unpin>(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<W: Write + Unpin>(stream: &mut W) -> Result {
if let Some(lang) = ARGS.language.as_deref() {
send_header(stream, 20, &["text/gemini;lang=", lang]).await