๐Ÿ A very simple static Gemini server, now with Titan support!
cpp gemini titan gemini-protocol titan-protocol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: cleanup non-essential variables

Fuwn dc8ce1e3 010009fd

+7 -16
+4 -15
maple/gemini.cc
··· 36 36 ".maple/gmi" + path 37 37 ) != gemini_files.end()) { 38 38 // If the route is a file being served; get the file contents 39 - 40 - std::ifstream file(".maple/gmi" + path); 41 - std::stringstream buffer; 42 - 43 - buffer << file.rdbuf(); 44 - 45 - file.close(); 46 - 47 - response << "20 text/gemini\r\n" << buffer.str(); 39 + response << "20 text/gemini\r\n" 40 + << std::ifstream(".maple/gmi" + path).rdbuf(); 48 41 } else { 49 42 if (path.empty() || path.at(path.length() - 1) == '/') { 50 - std::ifstream file(".maple/gmi" + path + "index.gmi"); 51 - std::stringstream buffer; 52 - 53 - buffer << file.rdbuf(); 54 - 55 - response << "20 text/gemini\r\n" << buffer.str(); 43 + response << "20 text/gemini\r\n" 44 + << std::ifstream(".maple/gmi" + path + "index.gmi").rdbuf(); 56 45 } else { 57 46 response 58 47 << "51 The server (Maple) could not find the specified file.\r\n";
+3 -1
maple/maple.cc
··· 190 190 reinterpret_cast<sockaddr *>(&socket_address_), 191 191 &socket_address_length 192 192 ); 193 - char request[1024]; 194 193 195 194 if (client < 0) { maple::exit_with("unable to accept", false); } 196 195 ··· 204 203 size_t index_of_junk; 205 204 int request_scheme; // Gemini = 1, Titan = 2, Error = 0 206 205 size_t bytes_read; 206 + char request[1024]; 207 207 208 208 SSL_read_ex(ssl, request, sizeof(request), &bytes_read); 209 209 ··· 291 291 namespace maple { 292 292 auto exit_with[[noreturn]](const char *message, bool ssl) -> void { 293 293 perror(message); 294 + 294 295 if (ssl) { ERR_print_errors_fp(stderr); } 296 + 295 297 std::exit(EXIT_FAILURE); 296 298 } 297 299 }