pub struct RequestCtx {Show 16 fields
pub output_buf: Vec<u8>,
pub request_body: Vec<u8>,
pub body_read_pos: usize,
pub cookie_header: Option<CString>,
pub response_headers: Vec<(String, String)>,
pub status_code: u16,
pub request_headers: Vec<(String, String)>,
pub remote_addr: Option<CString>,
pub server_name: Option<CString>,
pub server_port: u16,
pub https: bool,
pub document_root: Option<String>,
pub c_method: Option<CString>,
pub c_uri: Option<CString>,
pub c_query_string: Option<CString>,
pub c_content_type: Option<CString>,
}Expand description
Rust-side state for a single PHP request execution.
§Safety
Must remain pinned in memory for the duration of the PHP script execution. Owned exclusively by one worker thread — no concurrent access.
Fields§
§output_buf: Vec<u8>Accumulated PHP output (echo, print, etc.).
request_body: Vec<u8>Request body (POST/PUT data).
body_read_pos: usizeCurrent read position in request_body (for streaming reads).
Raw Cookie header (CString for C lifetime).
response_headers: Vec<(String, String)>Response headers from PHP header() calls.
status_code: u16HTTP status code set by PHP.
request_headers: Vec<(String, String)>Incoming HTTP request headers for $_SERVER.
remote_addr: Option<CString>Client IP (REMOTE_ADDR).
server_name: Option<CString>Server hostname (SERVER_NAME / HTTP_HOST).
server_port: u16Server port.
https: boolHTTPS flag.
document_root: Option<String>Document root path.
c_method: Option<CString>§c_uri: Option<CString>§c_query_string: Option<CString>§c_content_type: Option<CString>Implementations§
Source§impl RequestCtx
impl RequestCtx
Sourcepub fn new(
request_body: Vec<u8>,
cookie_header: Option<&str>,
request_headers: Vec<(String, String)>,
remote_addr: Option<&str>,
server_name: Option<&str>,
server_port: u16,
https: bool,
) -> Self
pub fn new( request_body: Vec<u8>, cookie_header: Option<&str>, request_headers: Vec<(String, String)>, remote_addr: Option<&str>, server_name: Option<&str>, server_port: u16, https: bool, ) -> Self
Create a new request context with full HTTP metadata.
Sourcepub fn set_request_info(
&mut self,
method: &str,
uri: &str,
query_string: &str,
content_type: Option<&str>,
)
pub fn set_request_info( &mut self, method: &str, uri: &str, query_string: &str, content_type: Option<&str>, )
Set request info fields (method, URI, query, content_type) as CStrings. These are read by C via the bext_sapi_get_* accessor callbacks.
Sourcepub fn reset_for_worker_request(&mut self, p: WorkerRequestParams<'_>)
pub fn reset_for_worker_request(&mut self, p: WorkerRequestParams<'_>)
Reset for the next request in worker mode. Clears output and response state but preserves connection metadata.