keep alive config settings
This commit is contained in:
parent
b15a198d2b
commit
cbd0067cb0
3
conf.yml
3
conf.yml
@ -6,9 +6,12 @@ sites:
|
||||
# host: localhost:8080
|
||||
# ssl_cert: "/path/to/public/certificate.txt"
|
||||
# ssl_key: "/path/to/private/key.txt"
|
||||
# support_keep_alive: true
|
||||
|
||||
# - domain: sub.example.com # Domain with no SSL
|
||||
# host: localhost:8081
|
||||
# support_keep_alive: true
|
||||
|
||||
- domain: localhost
|
||||
host: localhost:8080
|
||||
support_keep_alive: false
|
||||
|
@ -9,6 +9,7 @@ pub struct SiteConfig {
|
||||
pub domain: String,
|
||||
pub host: String,
|
||||
pub ssl: Option<SslCert>,
|
||||
pub support_keep_alive: bool
|
||||
}
|
||||
|
||||
impl SiteConfig {
|
||||
@ -53,6 +54,7 @@ impl Config {
|
||||
domain: s.get("domain")?.as_str()?.to_string(),
|
||||
host: s.get("host")?.as_str()?.to_string(),
|
||||
ssl: cert,
|
||||
support_keep_alive: s.get("support_keep_alive").map(|o| o.as_bool().unwrap()).unwrap_or(false)
|
||||
};
|
||||
|
||||
sites.push(site);
|
||||
|
@ -165,7 +165,7 @@ impl FlowgateServer {
|
||||
}
|
||||
|
||||
let site = site?.clone();
|
||||
let mut site_stream = site.connect()?;
|
||||
let mut site_stream = site.clone().connect()?;
|
||||
|
||||
site_stream.write((addr.to_string() + "\n" + reqst).as_bytes()).ok()?;
|
||||
|
||||
@ -195,6 +195,10 @@ impl FlowgateServer {
|
||||
|
||||
if keep_alive {
|
||||
loop {
|
||||
if !site.clone().support_keep_alive {
|
||||
site_stream.shutdown(Shutdown::Both).ok()?;
|
||||
}
|
||||
|
||||
let mut reqst_data: Vec<u8> = vec![0; 4096];
|
||||
|
||||
stream.read(&mut reqst_data).ok()?;
|
||||
@ -220,6 +224,10 @@ impl FlowgateServer {
|
||||
}
|
||||
}
|
||||
|
||||
if !site.clone().support_keep_alive {
|
||||
site_stream = site.clone().connect()?
|
||||
}
|
||||
|
||||
site_stream.write((addr.to_string() + "\n" + reqst).as_bytes()).ok()?;
|
||||
|
||||
if content_length != 0 && content_length > body.len() {
|
||||
|
Loading…
Reference in New Issue
Block a user