ErrorKind::Interrupted (libc::EINTR) errors should not break the
HttpServer requests loop, they are internally consumed and reported
as no events rather than requests errors.
Signed-off-by: Adrian Catangiu <acatan@amazon.com>
When doing IO with the underlying stream object, we should handle
the special case of ErrorKind::Interrupted, otherwise the connection
will be closed incorrectly.
Quotation from Rust doc:
An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
read operation should be retried if there is nothing else to do.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Route request according to {method, path} tuple, so we could use only
one router for each http server.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Previously the HttpRoute has logic to clone the handler parameter,
which is an implementation detail of the API server. So simplify
the HttpRoute interfaces by removing the argument cloning logic.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Import vmm/src/api/http.rs from Cloud Hyerpvisor project, commit
345c922cb9a88183e2da9d29230ecb945b0a6452 with following changes:
1) use generic type for handler argument.
2) remove server thread relative code.
3) add unit test cases.
4) refine for better code reuse.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
When closing a http connection, the corresponding file descriptor
should be unregistered from the epoll fd.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
It's almost an illegal input for a Content-Length header with negative
value, so reject it. Otherwise it may cause unexpected behavor when
parsing/receiving http requests.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
The readme is still WIP, but it was added so that we can have links
to the other documents in the repository.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
The linker was unable to find __addtf3, __multf3 and __subtf3.
Added target-feature=+crt-static and link-arg=-lgcc as a temporary
workaround. This seems to be the accepted fix in the Rust community:
rust-lang-nursery/compiler-builtins#201
A permanent fix is yet to be implemented in the Rust compiler.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
Pulled the code from firecracker-microvm/src/micro-http.
Signed-off-by: George Pisaltu <gpl@amazon.com>
Signed-off-by: Andreea Florescu <fandree@amazon.com>