@@ -16,21 +16,30 @@ DLLEXPORT int application_call(HttpServer::server_request *request, HttpServer::
1616 std::unordered_map<std::string, std::string> headers;
1717 std::unordered_multimap<std::string, std::string> data;
1818 std::unordered_multimap<std::string, HttpServer::FileIncoming> files;
19+ std::unordered_multimap<std::string, std::string> cookies;
1920
2021 Utils::rawPairsToStlUnorderedMultimap (params, request->params , request->params_count );
2122 Utils::rawPairsToStlUnorderedMap (headers, request->headers , request->headers_count );
2223 Utils::rawPairsToStlUnorderedMultimap (data, request->data , request->data_count );
2324 Utils::rawFilesInfoToFilesIncoming (files, request->files , request->files_count );
2425
26+ auto it_cookie = headers.find (" Cookie" );
27+
28+ if (headers.end () != it_cookie)
29+ {
30+ Utils::parseCookies (it_cookie->second , cookies);
31+ }
32+
2533 HttpServer::ServerRequest proc_request {
2634 HttpServer::Socket (request->socket ),
2735 std::string (request->method ),
2836 std::string (request->uri_reference ),
2937 std::string (request->document_root ),
30- params,
31- headers,
32- data,
33- files
38+ std::move (params),
39+ std::move (headers),
40+ std::move (data),
41+ std::move (files),
42+ std::move (cookies)
3443 };
3544
3645 HttpServer::ServerResponse proc_response {
@@ -42,11 +51,17 @@ DLLEXPORT int application_call(HttpServer::server_request *request, HttpServer::
4251
4352 int result = EXIT_SUCCESS;
4453
45- std::ifstream file (absolute_path);
54+ std::ifstream file (absolute_path, std::ifstream::binary );
4655
4756 if (file)
4857 {
49- proc_response.headers [" Connection" ] = " keep-alive" ;
58+ auto it_connection = proc_request.headers .find (" Connection" );
59+
60+ if (proc_request.headers .cend () != it_connection)
61+ {
62+ proc_response.headers [" Connection" ] = it_connection->second ;
63+ }
64+
5065 proc_response.headers [" X-Sendfile" ] = absolute_path;
5166 }
5267 else
0 commit comments