X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fshowcaptchapage.cpp;h=088fffa651d9df13ca9ab3120eb1352ac44dc168;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hp=46a4d3d1b56c3dd1529d22804b3bd7060b33502f;hpb=f60495a029c54358f82956482fe203fe2b7b5b23;p=fms.git diff --git a/src/http/pages/showcaptchapage.cpp b/src/http/pages/showcaptchapage.cpp index 46a4d3d..088fffa 100644 --- a/src/http/pages/showcaptchapage.cpp +++ b/src/http/pages/showcaptchapage.cpp @@ -6,9 +6,16 @@ #include #endif -const std::string ShowCaptchaPage::GeneratePage(const std::string &method, const std::map &queryvars) +void ShowCaptchaPage::handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) { - std::string content="HTTP/1.1 200 OK\r\n"; + m_log->trace("ShowCaptchaPage::handleRequest from "+request.clientAddress().toString()); + + std::map queryvars; + CreateQueryVarMap(request,queryvars); + + response.setChunkedTransferEncoding(true); + + std::string content=""; if(queryvars.find("UUID")!=queryvars.end()) { SQLite3DB::Statement st=m_db->Prepare("SELECT MimeType,PuzzleData FROM tblIntroductionPuzzleRequests WHERE Type='captcha' AND UUID=?;"); @@ -20,23 +27,23 @@ const std::string ShowCaptchaPage::GeneratePage(const std::string &method, const std::string mime; std::string b64data; std::vector data; - std::string lenstr; st.ResultText(0,mime); st.ResultText(1,b64data); Base64::Decode(b64data,data); - StringFunctions::Convert(data.size(),lenstr); // mime type should be short and have a / in it - otherwise skip if(mime.size()<50 && mime.find("/")!=std::string::npos) { - content+="Content-Type: "+mime+"\r\n"; - content+="Content-Length: "+lenstr+"\r\n\r\n"; + response.setContentType(mime); + response.setContentLength(data.size()); content+=std::string(data.begin(),data.end()); } } } - return content; + + std::ostream &ostr = response.send(); + ostr << content; } const bool ShowCaptchaPage::WillHandleURI(const std::string &uri)