@@ -117,8 +117,6 @@ void CKeePassIntegrator::init()
117117 sUrl = SecureString (" http://" );
118118 sUrl += SecureString (strKeePassEntryName.c_str ());
119119 sUrl += SecureString (" /" );
120- // sSubmitUrl = "http://";
121- // sSubmitUrl += SecureString(strKeePassEntryName.c_str());
122120 }
123121}
124122
@@ -288,28 +286,6 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
288286// Send RPC message to KeePassHttp
289287void CKeePassIntegrator::doHTTPPost (const std::string& sRequest , int & nStatusRet, std::string& strResponseRet)
290288{
291- // // Prepare communication
292- // boost::asio::io_service io_service;
293-
294- // // Get a list of endpoints corresponding to the server name.
295- // tcp::resolver resolver(io_service);
296- // tcp::resolver::query query(KEEPASS_HTTP_HOST, boost::lexical_cast<std::string>(nPort));
297- // tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
298- // tcp::resolver::iterator end;
299-
300- // // Try each endpoint until we successfully establish a connection.
301- // tcp::socket socket(io_service);
302- // boost::system::error_code error = boost::asio::error::host_not_found;
303- // while (error && endpoint_iterator != end)
304- // {
305- // socket.close();
306- // socket.connect(*endpoint_iterator++, error);
307- // }
308-
309- // if(error)
310- // {
311- // throw boost::system::system_error(error);
312- // }
313289 // Create event base
314290 struct event_base *base = event_base_new (); // TODO RAII
315291 if (!base)
@@ -321,53 +297,21 @@ void CKeePassIntegrator::doHTTPPost(const std::string& sRequest, int& nStatusRet
321297 throw std::runtime_error (" create connection failed" );
322298 evhttp_connection_set_timeout (evcon, KEEPASS_HTTP_CONNECT_TIMEOUT);
323299
324- // Form the request.
325- // std::map<std::string, std::string> mapRequestHeaders;
326- // std::string strPost = constructHTTPPost(sRequest, mapRequestHeaders);
327-
328300 HTTPReply response;
329301 struct evhttp_request *req = evhttp_request_new (http_request_done, (void *)&response); // TODO RAII
330302 if (req == nullptr )
331303 throw std::runtime_error (" create http request failed" );
332304
333305 struct evkeyvalq *output_headers = evhttp_request_get_output_headers (req);
334306 assert (output_headers);
335- // s << "POST / HTTP/1.1\r\n"
336307 evhttp_add_header (output_headers, " User-Agent" , (" dash-json-rpc/" + FormatFullVersion ()).c_str ());
337308 evhttp_add_header (output_headers, " Host" , KEEPASS_HTTP_HOST);
338309 evhttp_add_header (output_headers, " Accept" , " application/json" );
339310 evhttp_add_header (output_headers, " Content-Type" , " application/json" );
340- // evhttp_add_header(output_headers, "Content-Length", itostr(strMsg.size()).c_str());
341311 evhttp_add_header (output_headers, " Connection" , " close" );
342312
343- // Logging of actual post data disabled as to not write passphrase in debug.log. Only enable temporarily when needed
344- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- send POST data: %s\n", strPost);
345313 LogPrint (BCLog::KEEPASS, " CKeePassIntegrator::doHTTPPost -- send POST data\n " );
346314
347- // boost::asio::streambuf request;
348- // std::ostream request_stream(&request);
349- // request_stream << strPost;
350-
351- // // Send the request.
352- // boost::asio::write(socket, request);
353-
354- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- request written\n");
355-
356- // // Read the response status line. The response streambuf will automatically
357- // // grow to accommodate the entire line. The growth may be limited by passing
358- // // a maximum size to the streambuf constructor.
359- // boost::asio::streambuf response;
360- // boost::asio::read_until(socket, response, "\r\n");
361-
362- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- request status line read\n");
363-
364- // // Receive HTTP reply status
365- // int nProto = 0;
366- // std::istream response_stream(&response);
367- // nStatus = ReadHTTPStatus(response_stream, nProto);
368-
369- // Attach request data
370- // std::string sRequest = JSONRPCRequest(strMethod, params, 1);
371315 struct evbuffer * output_buffer = evhttp_request_get_output_buffer (req);
372316 assert (output_buffer);
373317 evbuffer_add (output_buffer, sRequest .data (), sRequest .size ());
@@ -383,25 +327,6 @@ void CKeePassIntegrator::doHTTPPost(const std::string& sRequest, int& nStatusRet
383327 evhttp_connection_free (evcon);
384328 event_base_free (base);
385329
386- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- reading response body start\n");
387- // // Read until EOF, writing data to output as we go.
388- // while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error))
389- // {
390- // if (error != boost::asio::error::eof)
391- // {
392- // if (error != 0)
393- // { // 0 is success
394- // throw boost::system::system_error(error);
395- // }
396- // }
397- // }
398- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- reading response body end\n");
399- //
400- // // Receive HTTP reply message headers and body
401- // std::map<std::string, std::string> mapHeaders;
402- // ReadHTTPMessage(response_stream, mapHeaders, strResponse, nProto, std::numeric_limits<size_t>::max());
403- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::doHTTPPost -- Processed body\n");
404-
405330 nStatusRet = response.nStatus ;
406331 if (response.nStatus == 0 )
407332 throw std::runtime_error (" couldn't connect to server" );
@@ -451,8 +376,6 @@ std::vector<CKeePassIntegrator::CKeePassEntry> CKeePassIntegrator::rpcGetLogins(
451376
452377 doHTTPPost (request.getJson (), nStatus, strResponse);
453378
454- // Logging of actual response data disabled as to not write passphrase in debug.log. Only enable temporarily when needed
455- // LogPrint(BCLog::KEEPASS, "CKeePassIntegrator::rpcGetLogins -- send result: status: %d response: %s\n", nStatus, strResponse);
456379 LogPrint (BCLog::KEEPASS, " CKeePassIntegrator::rpcGetLogins -- send result: status: %d\n " , nStatus);
457380
458381 if (nStatus != 200 )
0 commit comments