From 22872783724a978b47be647a731833b66d596950 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Mar 2026 19:27:35 +0000 Subject: [PATCH] Fix: include HTTP headers in Net.serve request record The request record passed to the handler callback was missing a "headers" field, causing E4008 "invalid field access: headers" when Astra programs tried to read incoming HTTP headers (e.g., req.headers.get("Authorization")). Extract headers from tiny_http::Request via .headers() and include them as a Map(Text -> Text) in the request record alongside the existing method, path, body, and query fields. https://claude.ai/code/session_01R4D7SMLBTSb1B4bPu11R3N --- src/interpreter/methods.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/interpreter/methods.rs b/src/interpreter/methods.rs index c920032..a3b678e 100644 --- a/src/interpreter/methods.rs +++ b/src/interpreter/methods.rs @@ -226,6 +226,18 @@ impl Interpreter { (full_url.clone(), Value::Map(Vec::new())) }; + // Extract headers + let headers_map: Vec<(Value, Value)> = request + .headers() + .iter() + .map(|h| { + ( + Value::Text(h.field.to_string()), + Value::Text(h.value.as_str().to_string()), + ) + }) + .collect(); + // Read body let mut body_buf = String::new(); let _ = request.as_reader().read_to_string(&mut body_buf); @@ -236,6 +248,7 @@ impl Interpreter { m.insert("path".to_string(), Value::Text(path_str)); m.insert("body".to_string(), Value::Text(body_buf)); m.insert("query".to_string(), query_map); + m.insert("headers".to_string(), Value::Map(headers_map)); m });