about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--parrot/Cargo.toml6
-rw-r--r--parrot/src/main.rs33
2 files changed, 39 insertions, 0 deletions
diff --git a/parrot/Cargo.toml b/parrot/Cargo.toml
new file mode 100644
index 0000000..1205841
--- /dev/null
+++ b/parrot/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "parrot"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/parrot/src/main.rs b/parrot/src/main.rs
new file mode 100644
index 0000000..d3fe60f
--- /dev/null
+++ b/parrot/src/main.rs
@@ -0,0 +1,33 @@
+use std::{
+	env,
+	fs::File,
+	io::{BufWriter, Read, Write},
+};
+
+fn main() {
+	println!("Content-Type: text/plain\n");
+
+	let mut bw = BufWriter::new(File::create("/tmp/parrot-debug").unwrap());
+
+	for (key, value) in env::vars() {
+		let log = format!("{key}: {value}\n");
+		print!("{log}");
+		bw.write_all(log.as_bytes()).unwrap();
+	}
+
+	let mut buf = vec![];
+	std::io::stdin().read_to_end(&mut buf).unwrap();
+
+	match std::str::from_utf8(&buf) {
+		Err(_e) => {
+			let log = format!("\n(binary data; {} bytes)\n", buf.len());
+			print!("{log}");
+			bw.write_all(log.as_bytes()).unwrap();
+		}
+		Ok(s) => {
+			let log = format!("\n{s}\n");
+			print!("{log}");
+			bw.write_all(log.as_bytes()).unwrap();
+		}
+	}
+}