Module async_fcgi::client::connection [−][src]
Expand description
A single connection (TCP or Unix) to an FCGI application.
Multiple Requests can be multiplexed on it.
Example
use std::collections::HashMap;
use http::{Request, StatusCode};
use http_body::Body;
use tokio::net::TcpStream;
use bytes::Bytes;
use async_fcgi::client::connection::Connection;
#[tokio::main]
async fn main() {
let mut fcgi_con = Connection::connect(&"127.0.0.1:59000".parse().unwrap(), 1).await.unwrap();
let req = Request::get("/test?lol=1").header("Accept", "text/html").body(()).unwrap();
let mut params = HashMap::new();
params.insert(
Bytes::from(&b"SCRIPT_FILENAME"[..]),
Bytes::from(&b"/home/daniel/Public/test.php"[..]),
);
let mut res = fcgi_con.forward(req,params).await.expect("forward failed");
assert_eq!(res.status(), StatusCode::NOT_FOUND);
assert_eq!(res.headers().get("X-Powered-By").expect("powered by header missing"), "PHP/7.3.16");
let read1 = res.data().await;
assert!(read1.is_some());
}Structs
Single transport connection to a FCGI application