Skip to main content

RequestCtx

Struct RequestCtx 

Source
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: usize

Current read position in request_body (for streaming reads).

§cookie_header: Option<CString>

Raw Cookie header (CString for C lifetime).

§response_headers: Vec<(String, String)>

Response headers from PHP header() calls.

§status_code: u16

HTTP 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: u16

Server port.

§https: bool

HTTPS 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

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more