This commit adds support for the `Deprecation` HTTP header based on
https://tools.ietf.org/id/draft-dalal-deprecation-header-03.html .
Users can set this header in a `Response` to send a
"Deprecation: true" header field back to the requester, signaling
that the resource accessed has been deprecated.
Signed-off-by: George Pisaltu <gpl@amazon.com>
The sever is now able to get any optional file descriptor that might
have been sent over with the bytes related to a request. This patch
leverages this ability by extending the Request structure with an
optional File, which might have been received from the byte stream.
With the Request containing an optional File, we give the consumers of
this crate the possibility to receive a file descriptor associated with
the HTTP request.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
The stream used by the Connection structure is expected to implement
both Read and Write traits. Since we want the server to be able to
receive file descriptors through control messages mechanism, this patch
extends the expectations regarding the stream by adding ScmSocket to the
list of traits.
Since the stream is a UnixStream structure, and since vmm-sys-util
already provides an ScmSocket implementation for UnixStream, extending
the list of traits is very straightforward.
Relying on the newly added trait, the server now reads incoming bytes
through recv_with_fd() function, which replaces the former call to
read(). This change has no intent of modifying the former behavior from
the read(), which is why the returned Option<File> is ignored for now.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Allow the creation of the http server's socket from an existing
fd. This is done to enable another process to initiate the creation of
a server by preparing the socket so it can immediately be used rather
than polling to connect to the path.
Note, the coverage file change due to what appears to be a rounding
error when calculating coverage.
Signed-off-by: William Douglas <william.douglas@intel.com>
The server in `micro_http` was not explicitly handling the `EPOLLHUP`,
`EPOLLRDHUP` and `EPOLLERR` epoll events. Added new checks that close
a connection that is signaled with these events.
Signed-off-by: George Pisaltu <gpl@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
This commit adds a mechanism that considers
some errors as 'fatal'. It alerts the user and then
terminates the Firecracker process.
Signed-off-by: berciuliviu <lberciu@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Changed the way we handle TransferEncoding
and added new test cases.
Signed-off-by: cihodar <cihodar@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
In Rust 2018 edition, it is considered unidiomatic to use "extern crate"
sunthax. The proper way to do it is to replace extern crate with "use"
declarations.
- Also impl clippy suggestions for fn main removal in doctests
- Fix unneeded box allocations and clones
Signed-off-by: Damien Stanton <damien.stanton@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
...and a bunch of fixes for unchecked unsigned arithmetic
in connection.rs. Added more unit tests too that exercise
failure cases for over/underflows in mathematic operations.
Fixes#1977
Signed-off-by: Alexandra Iordache <aghecen@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Any number of whitespace characters are accepted after ":"
when parsing HTTP headers.
Create a test function (Add test_parse_header_whitespace).
This test addresses parsing header and allow no space and
any amount of linear white space after ":". And modified
CHANGELOG.md.
Signed-off-by: Eisuke Matsushita <ei13suke@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
When server returns `Method Not Allow` responses,
it can attach to the response a HTTP `Allow` header.
Added support for HTTP response `Allow` header as
well.
Signed-off-by: Iulian Barbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Added a new API for configuring MMDS. At the moment,
this configuration applies only for the MMDS IPv4 address.
Besides the new API, this commits comprises changes to the
NetBuilder implementation and usages.
Signed-off-by: iulianbarbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
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>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Move epoll.rs from polly to utils crate and use this file,
in micro_http, as an epoll wrapper instead of the epoll crate.
Signed-off-by: Laura Loghin <lauralg@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Add some test cases for uri test, to cover sub-domain uri
and `ip:port`.
Refactor `test_uri` and `test_find`. Leverage tupled vector
to init test inputs and expected values, and remove superfluous
lines. It will be more flexible to modify the test cases.
Signed-off-by: keyangxie <keyang.xie@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
Use case-insensitive check since some http clients use lower case
headers.
Signed-off-by: Bob Potter <bobby.potter@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
When we are not capable to provide a certain kind of service, but should be
after some delay. Http server is better to reply status code 503. It is more
suggestive per as to http spec.
```
The server is currently unable to handle the request due to a temporary
overload or scheduled maintenance, which will likely be alleviated after some delay.
```
Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
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>