drogonframework / drogonframework/drogon

HTTP – Response Doesn’t Have a Notification

Open
#1,469 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

The HTTP response function is working as async and there is no notification. As far as we observe, it causes some problems. There are two types of newFileResponse functions. One of these is working with a file path. When we give the file path and execute the response function, we cannot ensure that the process is done. If we remove the file after the response function execution, the drogon library could not find the file and the response cannot send to the client properly. In addition to this, another newFileResponse function is working with files in memory. If we use it, the function copies the file and the library uses the copied file. It could be a waste of memory usage. In our opinion, the library can notify the user when the response is completed with a result code. Hence, we can remove the file from the file system or memory, in addition to this, the library can use the given file in memory with no need for an extra copy.

Example problematic newFileResponse code with file path:

`void handle_request(const drogon::HttpRequestPtr &req,
std::function &&callback,
...) {
...
drogon::HttpResponsePtr resp = drogon::HttpResponse::newFileResponse(file_path, file_name, drogon::ContentType::CT_CUSTOM, mime_type);
callback(resp);
remove(file_path);
...
}
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.