From 10925e207a28635e207459c5b78581385c9dbe9e Mon Sep 17 00:00:00 2001 From: gennyble Date: Wed, 2 Apr 2025 06:53:54 -0500 Subject: remember to remove old ffi structs in corgi when using smalldog --- corgi/src/caller.rs | 33 +++++++++++---------------------- smalldog/README.md | 4 ++-- stats_module/src/lib.rs | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/corgi/src/caller.rs b/corgi/src/caller.rs index 4f75d32..aef6bc3 100644 --- a/corgi/src/caller.rs +++ b/corgi/src/caller.rs @@ -1,11 +1,13 @@ use std::{ ffi::{self, CString}, + marker::PhantomData, net::IpAddr, process::Stdio, ptr, str::FromStr, }; +use smalldog::ffi::{ModuleRequest, ModuleResponse}; use tokio::{ io::AsyncWriteExt, process::Command, @@ -168,23 +170,6 @@ pub struct CgiResponse { pub body: Option>, } -#[repr(C)] -struct ModuleRequest { - headers_len: ffi::c_ulong, - headers: *const [[*const ffi::c_char; 2]], - body_len: ffi::c_ulong, - body: *const u8, -} - -#[repr(C)] -struct ModuleResponse { - status: ffi::c_ushort, - headers_len: ffi::c_ulong, - headers: &'static [[*const ffi::c_char; 2]], - body_len: ffi::c_ulong, - body: *const u8, -} - type HandleFn = unsafe extern "C" fn(*const ModuleRequest) -> *const ModuleResponse; type CleanupFn = unsafe extern "C" fn(*const ModuleResponse); @@ -216,9 +201,10 @@ unsafe fn module_thread(script: Script, req: HttpRequest, tx: Sender *const ffi::ModuleRe } body.push_str("

"); - response.body(body.into_bytes()); + response.body(body.into_bytes()).header(c"Content-Type", c"text/html"); response.into_mod_response(200) } -- cgit 1.4.1-3-g733a5