This memory leak was caused from the fact that we were creating a raw
pointers in the do_accept method of the http_server. The initial
connection was never released, but all subsequent connection
were released without problem. So this commit introduces shared_ptr
to manage all the connection and release the memory when the
connection is not needed any more.
Signed-off-by: Vasileios Anagnostopoulos <anagnwstopoulos@hotmail.com>
- Added methods to get usefull information about running server instance:
std::uint16_t port() -> Get the port that Crow will handle requests on
std::string bindaddr() -> Get the address that Crow will handle requests on
std::uint16_t concurrency() -> Get the number of threads that server is using
* Added tests for content-type to mime-type detection.
Added a custom_content_types test case that verifies that a user can
specify the mime-type through the contentType parameter upon creation
of a response. If their contentType does not appear in the mime_types
map, but looks like a valid mime type already, it should be used as the
mime type.
Validating against the full list of valid mime types
(https://www.iana.org/assignments/media-types/media-types.xhtml)
would be too intensive, so we merely verify that the parent type
(application, audio, font, text, image, etc) is a valid RFC6838
type, and that the subtype is at least one character. Thus we can
verify that custom/type fails, and incomplete strings such as
image/ and /json fail.
16KiB. It could also cause to return partially incorrect file ending in
case of file not being rounded up to 16KiB.
Thanks to Gynvael Coldwind and hebi for discovering and preparing
report.
On gcc < 8, filesystem had to be included as <experimental/filesystem>, it
was also living in the std::experimental namespace, and also required the user
to link against -lstdc++fs.
Defining a HEAD method would give HTTP error code 405 (Method Not Allowed) and
calling OPTIONS on the route would return HEAD twice in the Allow header.