Struct async_fcgi::client::connection::Connection
source · pub struct Connection { /* private fields */ }
Expand description
Single transport connection to a FCGI application
Can multiplex max_req_per_con
simultaneous request streams
Implementations§
source§impl Connection
impl Connection
sourcepub async fn connect(
addr: &FCGIAddr,
max_req_per_con: u16
) -> Result<Connection, Box<dyn Error>>
pub async fn connect( addr: &FCGIAddr, max_req_per_con: u16 ) -> Result<Connection, Box<dyn Error>>
Connect to a peer with MultiHeaderStrategy::OnlyFirst
& HeaderMultilineStrategy::Ignore
.
sourcepub async fn connect_with_strategy(
addr: &FCGIAddr,
max_req_per_con: u16,
header_mul: MultiHeaderStrategy,
header_nl: HeaderMultilineStrategy
) -> Result<Connection, Box<dyn Error>>
pub async fn connect_with_strategy( addr: &FCGIAddr, max_req_per_con: u16, header_mul: MultiHeaderStrategy, header_nl: HeaderMultilineStrategy ) -> Result<Connection, Box<dyn Error>>
Connect to a peer
sourcepub fn is_ready(&self) -> bool
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
pub async fn close(self) -> Result<(), IoError>
sourcepub 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,
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(Empty::<Bytes>::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):
Param | Specification | Info |
---|---|---|
SCRIPT_NAME | must CGI/1.1 4.1.13 | required in any case |
SERVER_NAME | must CGI/1.1 4.1.14 | required by flup |
SERVER_PORT | must CGI/1.1 4.1.15 | required by flup |
SERVER_PROTOCOL | must CGI/1.1 4.1.16 | required by flup |
SERVER_SOFTWARE | must CGI/1.1 4.1.17 | |
REMOTE_ADDR | must CGI/1.1 4.1.8 | |
GATEWAY_INTERFACE | must CGI/1.1 4.1.4 | "CGI/1.1" |
REMOTE_HOST | should CGI/1.1 4.1.9 | |
REMOTE_IDENT | may CGI/1.1 4.1.10 | |
REMOTE_USER | opt CGI/1.1 | |
AUTH_TYPE | opt CGI/1.1 | |
PATH_INFO | opt CGI/1.1 4.1.5 | extra-path |
PATH_TRANSLATED | opt CGI/1.1 4.1.6 | |
SCRIPT_FILENAME | required by PHP | |
REMOTE_PORT | common | |
SERVER_ADDR | common | |
REQUEST_URI | common | |
DOCUMENT_URI | common | |
DOCUMENT_ROOT | common |