mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
proxy server: send values in batches
This commit is contained in:
1 parent
3490b19fe3
commit
fc95c85983
1 file changed
+6
-5
@@ -524,9 +524,11 @@ DhtProxyServer::get(restinio::request_handle_t request,
|
||||
auto response = std::make_shared<ResponseByPartsBuilder>(
|
||||
initHttpResponse(request->create_response<ResponseByParts>()));
|
||||
response->flush();
|
||||
dht_->get(infoHash, [this, response](const Sp<Value>& value){
|
||||
auto output = Json::writeString(jsonBuilder_, value->toJson()) + "\n";
|
||||
response->append_chunk(output);
|
||||
dht_->get(infoHash, [this, response](const std::vector<Sp<Value>>& values) {
|
||||
for (const auto& value : values) {
|
||||
auto output = Json::writeString(jsonBuilder_, value->toJson()) + "\n";
|
||||
response->append_chunk(output);
|
||||
}
|
||||
response->flush();
|
||||
return true;
|
||||
},
|
||||
@@ -1093,9 +1095,8 @@ DhtProxyServer::putEncrypted(restinio::request_handle_t request,
|
||||
auto value = std::make_shared<Value>(root);
|
||||
dht_->putEncrypted(infoHash, to, value, [this, request, value](bool ok){
|
||||
if (ok){
|
||||
auto output = Json::writeString(jsonBuilder_, value->toJson()) + "\n";
|
||||
auto response = initHttpResponse(request->create_response());
|
||||
response.append_body(output);
|
||||
response.append_body(Json::writeString(jsonBuilder_, value->toJson()) + "\n");
|
||||
response.done();
|
||||
} else {
|
||||
auto response = initHttpResponse(request->create_response(restinio::status_bad_gateway()));
|
||||
|
||||
Reference in new issue
Block a user