Mercurial > hg > orthanc
comparison Core/HttpServer/FilesystemHttpHandler.cpp @ 908:e078ea944089 plugins
refactoring HttpOutput
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Jun 2014 17:47:39 +0200 |
parents | 7d88f3f4a3b3 |
children | 8d1845feb277 |
comparison
equal
deleted
inserted
replaced
907:9b8298234254 | 908:e078ea944089 |
---|---|
54 const boost::filesystem::path& p) | 54 const boost::filesystem::path& p) |
55 { | 55 { |
56 namespace fs = boost::filesystem; | 56 namespace fs = boost::filesystem; |
57 | 57 |
58 output.SendOkHeader("text/html", false, 0, NULL); | 58 output.SendOkHeader("text/html", false, 0, NULL); |
59 output.SendString("<html>"); | 59 output.SendBodyString("<html>"); |
60 output.SendString(" <body>"); | 60 output.SendBodyString(" <body>"); |
61 output.SendString(" <h1>Subdirectories</h1>"); | 61 output.SendBodyString(" <h1>Subdirectories</h1>"); |
62 output.SendString(" <ul>"); | 62 output.SendBodyString(" <ul>"); |
63 | 63 |
64 if (uri.size() > 0) | 64 if (uri.size() > 0) |
65 { | 65 { |
66 std::string h = Toolbox::FlattenUri(uri) + "/.."; | 66 std::string h = Toolbox::FlattenUri(uri) + "/.."; |
67 output.SendString("<li><a href=\"" + h + "\">..</a></li>"); | 67 output.SendBodyString("<li><a href=\"" + h + "\">..</a></li>"); |
68 } | 68 } |
69 | 69 |
70 fs::directory_iterator end; | 70 fs::directory_iterator end; |
71 for (fs::directory_iterator it(p) ; it != end; ++it) | 71 for (fs::directory_iterator it(p) ; it != end; ++it) |
72 { | 72 { |
76 std::string f = it->path().filename(); | 76 std::string f = it->path().filename(); |
77 #endif | 77 #endif |
78 | 78 |
79 std::string h = Toolbox::FlattenUri(uri) + "/" + f; | 79 std::string h = Toolbox::FlattenUri(uri) + "/" + f; |
80 if (fs::is_directory(it->status())) | 80 if (fs::is_directory(it->status())) |
81 output.SendString("<li><a href=\"" + h + "\">" + f + "</a></li>"); | 81 output.SendBodyString("<li><a href=\"" + h + "\">" + f + "</a></li>"); |
82 } | 82 } |
83 | 83 |
84 output.SendString(" </ul>"); | 84 output.SendBodyString(" </ul>"); |
85 output.SendString(" <h1>Files</h1>"); | 85 output.SendBodyString(" <h1>Files</h1>"); |
86 output.SendString(" <ul>"); | 86 output.SendBodyString(" <ul>"); |
87 | 87 |
88 for (fs::directory_iterator it(p) ; it != end; ++it) | 88 for (fs::directory_iterator it(p) ; it != end; ++it) |
89 { | 89 { |
90 #if BOOST_HAS_FILESYSTEM_V3 == 1 | 90 #if BOOST_HAS_FILESYSTEM_V3 == 1 |
91 std::string f = it->path().filename().string(); | 91 std::string f = it->path().filename().string(); |
93 std::string f = it->path().filename(); | 93 std::string f = it->path().filename(); |
94 #endif | 94 #endif |
95 | 95 |
96 std::string h = Toolbox::FlattenUri(uri) + "/" + f; | 96 std::string h = Toolbox::FlattenUri(uri) + "/" + f; |
97 if (fs::is_regular_file(it->status())) | 97 if (fs::is_regular_file(it->status())) |
98 output.SendString("<li><a href=\"" + h + "\">" + f + "</a></li>"); | 98 output.SendBodyString("<li><a href=\"" + h + "\">" + f + "</a></li>"); |
99 } | 99 } |
100 | 100 |
101 output.SendString(" </ul>"); | 101 output.SendBodyString(" </ul>"); |
102 output.SendString(" </body>"); | 102 output.SendBodyString(" </body>"); |
103 output.SendString("</html>"); | 103 output.SendBodyString("</html>"); |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 FilesystemHttpHandler::FilesystemHttpHandler(const std::string& baseUri, | 107 FilesystemHttpHandler::FilesystemHttpHandler(const std::string& baseUri, |
108 const std::string& root) : pimpl_(new PImpl) | 108 const std::string& root) : pimpl_(new PImpl) |