EC2 IMDS includes X-Aws-Ec2-Metadata-Token-Ttl-Seconds header in the
response to PUT /latest/api/token. To enable Firecracker MMDS to behave
compatibly with EC2 IMDS, allow to set custom headers in HTTP response.
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The client may wait for the server to close the connection or for
timeout to occur in some cases. This commit changes it to always set
Content-Length field in non-100/204 responses regardless of whether
the body is empty. Although it doesn't cover all the patterns where
the response must not set it, users can remove it by calling
`set_content_length(None)`.
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Additionally, HttpServer::new_from_fd has been marked as unsafe,
since the correctness of the unsafe call within the function
relies on the caller upholding an invariant
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>