Switch HTTP server to HTTP 1.1 (#395)

* Switch to connection keep-alive

* Upgrade to HTTP 1.1

* Add pcap to makefile
This commit is contained in:
Vincent Ollivier 2022-08-27 12:36:20 +02:00 committed by GitHub
parent d965a72a81
commit 7f3baa2c60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -57,6 +57,10 @@ else
opts += -cpu max
endif
ifeq ($(pcap),true)
opts += -object filter-dump,id=f1,netdev=e0,file=/tmp/qemu.pcap
endif
ifeq ($(output),serial)
opts += -display none -chardev stdio,id=s0,signal=off -serial chardev:s0
endif

View File

@ -98,7 +98,7 @@ impl Response {
pub fn end(&mut self) {
self.size = self.body.len();
self.headers.insert("Content-Length".to_string(), self.size.to_string());
self.headers.insert("Connection".to_string(), "close".to_string());
self.headers.insert("Connection".to_string(), "keep-alive".to_string());
self.headers.insert("Content-Type".to_string(), if self.mime.starts_with("text/") {
format!("{}; charset=utf-8", self.mime)
} else {
@ -127,7 +127,7 @@ impl Response {
500 => "Internal Server Error",
_ => "Unknown Error",
};
format!("HTTP/1.0 {} {}", self.code, msg)
format!("HTTP/1.1 {} {}", self.code, msg)
}
}