Receive multiple file descriptors with a Request

Extending the existing code to support receiving more than one file
descriptor per request. The micro-http crate might be used in a context
where multiple file descriptors are associated with one request, hence
the need to update the micro-http crate.

A concrete example from Cloud Hypervisor is to be able to pass multiple
TAP file descriptors at once when adding a new network interface. This
way it can hotplug a multiqueue device.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-01-20 17:03:01 +01:00
committed by georgepisaltu
parent 0a58eb1ece
commit a730d86940
4 changed files with 145 additions and 33 deletions

View File

@@ -159,8 +159,8 @@ pub struct Request {
pub headers: Headers,
/// The body of the request.
pub body: Option<Body>,
/// The optional file associated with the request.
pub file: Option<File>,
/// The optional files associated with the request.
pub files: Vec<File>,
}
impl Request {
@@ -220,7 +220,7 @@ impl Request {
request_line,
headers: Headers::default(),
body: None,
file: None,
files: Vec::new(),
}),
Some(headers_end) => {
// Parse the request headers.
@@ -280,7 +280,7 @@ impl Request {
request_line,
headers,
body,
file: None,
files: Vec::new(),
})
}
// If we can't find a CR LF CR LF even though the request should have headers
@@ -449,7 +449,7 @@ mod tests {
uri: Uri::new("http://localhost/home"),
},
body: None,
file: None,
files: Vec::new(),
headers: Headers::default(),
};
let request_bytes = b"GET http://localhost/home HTTP/1.0\r\n\