Struct Connection

Source
pub struct Connection { /* private fields */ }
Available on crate feature web_server only.
Expand description

Single transport connection to a FCGI application

Can multiplex max_req_per_con simultaneous request streams

Implementations§

Source§

impl Connection

Source

pub async fn connect( addr: &Addr, max_req_per_con: u16, ) -> Result<Connection, Box<dyn Error>>

Source

pub async fn connect_with_strategy( addr: &Addr, max_req_per_con: u16, header_mul: MultiHeaderStrategy, header_nl: HeaderMultilineStrategy, ) -> Result<Connection, Box<dyn Error>>

Connect to a peer

Source

pub fn is_ready(&self) -> bool

true if the next call to forward does not need to wait for the end of some previous request

Source

pub async fn close(self) -> Result<(), IoError>

Source

pub async fn forward<B, I, P1, P2>( &self, req: Request<B>, dyn_headers: I, ) -> Result<Response<impl Body<Data = Bytes, Error = IoError>>, IoError>
where B: Body + Unpin, I: IntoIterator<Item = (P1, P2)>, P1: Buf, P2: Buf,

Forwards an HTTP request to a FGCI Application

let req = Request::get("/test?lol=1").header("Accept", "text/html").body(String::new())?;
let mut params = [(
    &b"SCRIPT_FILENAME"[..],
    &b"/home/daniel/Public/test.php"[..]
)];
let mut res = fcgi_con.forward(req, params).await?;

Fills QUERY_STRING, REQUEST_METHOD, CONTENT_TYPE and CONTENT_LENGTH from the corresponding values in the Request. Headers from the Request will be added with the HTTP_ prefix. (CGI/1.1 4.1.18)

Additional Params might be expected from the application (at least the url path):

ParamSpecificationInfo
SCRIPT_NAMEmust CGI/1.1 4.1.13required in any case
SERVER_NAMEmust CGI/1.1 4.1.14required by flup
SERVER_PORTmust CGI/1.1 4.1.15required by flup
SERVER_PROTOCOLmust CGI/1.1 4.1.16required by flup
SERVER_SOFTWAREmust CGI/1.1 4.1.17
REMOTE_ADDRmust CGI/1.1 4.1.8
GATEWAY_INTERFACEmust CGI/1.1 4.1.4"CGI/1.1"
REMOTE_HOSTshould CGI/1.1 4.1.9
REMOTE_IDENTmay CGI/1.1 4.1.10
REMOTE_USERopt CGI/1.1
AUTH_TYPEopt CGI/1.1
PATH_INFOopt CGI/1.1 4.1.5extra-path
PATH_TRANSLATEDopt CGI/1.1 4.1.6
SCRIPT_FILENAMErequired by PHP
REMOTE_PORTcommon
SERVER_ADDRcommon
REQUEST_URIcommon
DOCUMENT_URIcommon
DOCUMENT_ROOTcommon

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, 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.