comparison Core/HttpServer/FilesystemHttpHandler.cpp @ 1515:c94353fbd4e9

cont http compression
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Aug 2015 17:18:36 +0200
parents 8dc80ba768aa
children 4f8c8ef114db
comparison
equal deleted inserted replaced
1514:d73a2178b319 1515:c94353fbd4e9
48 }; 48 };
49 49
50 50
51 51
52 static void OutputDirectoryContent(HttpOutput& output, 52 static void OutputDirectoryContent(HttpOutput& output,
53 const IHttpHandler::Arguments& headers,
53 const UriComponents& uri, 54 const UriComponents& uri,
54 const boost::filesystem::path& p) 55 const boost::filesystem::path& p)
55 { 56 {
56 namespace fs = boost::filesystem; 57 namespace fs = boost::filesystem;
57 58
102 103
103 s += " </ul>"; 104 s += " </ul>";
104 s += " </body>"; 105 s += " </body>";
105 s += "</html>"; 106 s += "</html>";
106 107
107 output.SendBody(s); 108 output.SendBody(s, IHttpHandler::GetPreferredCompression(headers, s.size()));
108 } 109 }
109 110
110 111
111 FilesystemHttpHandler::FilesystemHttpHandler(const std::string& baseUri, 112 FilesystemHttpHandler::FilesystemHttpHandler(const std::string& baseUri,
112 const std::string& root) : pimpl_(new PImpl) 113 const std::string& root) : pimpl_(new PImpl)
153 p /= uri[i]; 154 p /= uri[i];
154 } 155 }
155 156
156 if (fs::exists(p) && fs::is_regular_file(p)) 157 if (fs::exists(p) && fs::is_regular_file(p))
157 { 158 {
158 FilesystemHttpSender(p).Send(output); 159 FilesystemHttpSender(p).Send(output); // TODO COMPRESSION
159 160
160 //output.AnswerFileAutodetectContentType(p.string()); 161 //output.AnswerFileAutodetectContentType(p.string());
161 } 162 }
162 else if (listDirectoryContent_ && 163 else if (listDirectoryContent_ &&
163 fs::exists(p) && 164 fs::exists(p) &&
164 fs::is_directory(p)) 165 fs::is_directory(p))
165 { 166 {
166 OutputDirectoryContent(output, uri, p); 167 OutputDirectoryContent(output, headers, uri, p);
167 } 168 }
168 else 169 else
169 { 170 {
170 output.SendStatus(HttpStatus_404_NotFound); 171 output.SendStatus(HttpStatus_404_NotFound);
171 } 172 }