mirror of https://github.com/CrowCpp/Crow.git
Create failing test.
This commit is contained in:
parent
db53bd619b
commit
bdfd9cb6a9
|
@ -0,0 +1 @@
|
|||
Test file with a strange extension.
|
|
@ -1926,8 +1926,10 @@ TEST_CASE("multipart")
|
|||
TEST_CASE("send_file")
|
||||
{
|
||||
|
||||
struct stat statbuf;
|
||||
stat("tests/img/cat.jpg", &statbuf);
|
||||
struct stat statbuf_cat;
|
||||
stat("tests/img/cat.jpg", &statbuf_cat);
|
||||
struct stat statbuf_badext;
|
||||
stat("tests/img/filewith.badext", &statbuf_badext);
|
||||
|
||||
SimpleApp app;
|
||||
|
||||
|
@ -1944,6 +1946,12 @@ TEST_CASE("send_file")
|
|||
res.end();
|
||||
});
|
||||
|
||||
CROW_ROUTE(app, "/filewith.badext")
|
||||
([](const crow::request&, crow::response& res) {
|
||||
res.set_static_file_info("tests/img/filewith.badext");
|
||||
res.end();
|
||||
});
|
||||
|
||||
app.validate();
|
||||
|
||||
//File not found check
|
||||
|
@ -1971,7 +1979,21 @@ TEST_CASE("send_file")
|
|||
|
||||
CHECK(200 == res.code);
|
||||
CHECK("image/jpeg" == res.headers.find("Content-Type")->second);
|
||||
CHECK(to_string(statbuf.st_size) == res.headers.find("Content-Length")->second);
|
||||
CHECK(to_string(statbuf_cat.st_size) == res.headers.find("Content-Length")->second);
|
||||
}
|
||||
|
||||
//Unknown extension check
|
||||
{
|
||||
request req;
|
||||
response res;
|
||||
|
||||
req.url = "/filewith.badext";
|
||||
req.http_ver_major = 1;
|
||||
|
||||
CHECK_NOTHROW(app.handle(req, res));
|
||||
CHECK(200 == res.code);
|
||||
CHECK("text/plain" == res.headers.find("Content-Type")->second);
|
||||
CHECK(to_string(statbuf_badext.st_size) == res.headers.find("Content-Length")->second);
|
||||
}
|
||||
} // send_file
|
||||
|
||||
|
|
Loading…
Reference in New Issue