aboutsummaryrefslogtreecommitdiff
path: root/maple/maple.cc
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-12-06 08:10:31 +0000
committerFuwn <[email protected]>2025-12-06 08:10:31 +0000
commiteeea40d4a1cc16283ec41d0a20e1f430fa0389c7 (patch)
tree81e132759dab9490e0141cd3f24cff8aba79207b /maple/maple.cc
parentchore: Support macOS (diff)
downloadarchived-maple-eeea40d4a1cc16283ec41d0a20e1f430fa0389c7.tar.xz
archived-maple-eeea40d4a1cc16283ec41d0a20e1f430fa0389c7.zip
refactor: Optimise request handling and harden Titan parameter parsing
Diffstat (limited to 'maple/maple.cc')
-rw-r--r--maple/maple.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/maple/maple.cc b/maple/maple.cc
index 1a1ba5c..71ad82f 100644
--- a/maple/maple.cc
+++ b/maple/maple.cc
@@ -119,8 +119,7 @@ auto main() -> int {
std::array<char, GEMINI_MAXIMUM_REQUEST_SIZE> request{};
SSL_read_ex(ssl, request.begin(), request.size(), &bytes_read);
-
- std::string path(request.data());
+ std::string path(request.data(), bytes_read);
if (path.starts_with("gemini://")) {
request_scheme = 1;
@@ -131,11 +130,9 @@ auto main() -> int {
}
if (request_scheme != 0) {
- path = path.substr(0, bytes_read);
-
// Remove "\r\n" if Gemini
if (request_scheme == 1) {
- path = path.substr(0, path.size() - 2);
+ path.resize(path.size() - 2);
}
if (request_scheme == 1) {
@@ -181,8 +178,10 @@ auto main() -> int {
}
}
- SSL_write(ssl, response.str().c_str(),
- static_cast<int>(response.str().size()));
+ const std::string response_string = response.str();
+
+ SSL_write(ssl, response_string.c_str(),
+ static_cast<int>(response_string.size()));
} else {
std::cout << "received a request with an unsupported url scheme\n";
}