Commit Graph

23 Commits

Author SHA1 Message Date
timvisee
3e888638e5 Implement clippy suggestions for Rust 1.43.1
Signed-off-by: timvisee <tim@visee.me>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Shion Yamashita
2e3f629054 micro_http: fix name of helper function in tests
Signed-off-by: Shion Yamashita <shioyama1118@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Shion Yamashita
d7a7bd0fe2 Use TempFile when generating path to socket
Signed-off-by: Shion Yamashita <shioyama1118@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Iulian Barbu
d37f9671af micro-http: added MethodNotAllow status code
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>
2021-04-15 11:21:32 +03:00
Iulian Barbu
530b36bfd9 micro_http: add support for accept headers
Signed-off-by: Iulian Barbu <iul@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
iulianbarbu
4a25226f2a mmds: added support for custom ipv4 address
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>
2021-04-15 11:21:32 +03:00
Adrian Catangiu
d288940391 micro_http: gracefully handle EINTR
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>
2021-04-15 11:21:32 +03:00
Popa
7eb11b44cb clean-up: get rid of misplaced cfg(test)
Signed-off-by: Popa <dpopa@amazon.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Laura Loghin
548d297be7 Completely remove epoll crate dependency
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>
2021-04-15 11:21:32 +03:00
keyangxie
7289d64e24 micro_http: update unit test
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>
2021-04-15 11:21:32 +03:00
karthik nedunchezhiyan
569230220f micro_http: some doc and code corrections
Signed-off-by: karthik nedunchezhiyan <karthik1705.n@gmail.com>
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
2021-04-15 11:21:32 +03:00
Bob Potter
4ee7142098 micro_http: adjust match on header fields
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>
2021-04-15 11:21:32 +03:00
Changwei Ge
59ab64440a Add http status code 503
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>
2020-11-03 08:38:02 +02:00
Adrian Catangiu
c33861a13b Handle ErrorKind::Interrupted when waiting for events
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>
2020-07-23 18:17:33 +03:00
Liu Jiang
c9ffb90aeb Handle ErrorKind::Interrupted when doing stream IO
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>
2020-04-27 09:41:16 +03:00
Liu Jiang
0d87a94c8e Route request according to {method, path} tuple
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>
2020-03-30 13:52:34 +03:00
Liu Jiang
8ca0839b58 Simplify the HttpRoute trait
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>
2020-03-30 13:52:34 +03:00
Liu Jiang
ac3bb940ab Import http routes from Cloud Hypervisor project
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>
2020-03-30 13:52:34 +03:00
Liu Jiang
31bc6268c7 Unregister fd from epoll_fd when closing a connection
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>
2020-03-30 13:52:34 +03:00
Liu Jiang
3832d38d8c Reject negative content length in http header
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>
2020-03-30 13:52:34 +03:00
Liu Jiang
aefdd1be46 Refine documentation according to latest code
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Liu Jiang
fbb4d5392a Refine code for rust edition 2018
Refine code to support rust edition 2018, no functional changes.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-03-30 13:52:34 +03:00
Andreea Florescu
6708271862 initial commit
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>
2020-01-27 12:28:50 +02:00