| 315 | } |
| 316 | |
| 317 | void RemoteDownloader::loadRemote(const Shared<RemoteDownloaderTask>& task) { |
| 318 | auto requestManager = getRequestManager(); |
| 319 | |
| 320 | if (requestManager == nullptr) { |
| 321 | loadCompleted(task, Error(STRING_LITERAL("No RequestManager set in the RemoteDownloader")), false); |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | int32_t priority = 4; |
| 326 | |
| 327 | static auto kGetMethod = STRING_LITERAL("GET"); |
| 328 | |
| 329 | snap::valdi_core::HTTPRequest request(task->getUrl(), kGetMethod, Value(), {}, priority); |
| 330 | |
| 331 | VALDI_INFO(_logger, "Starting load of {} at {}", task->getItemDescription(), task->getUrl()); |
| 332 | |
| 333 | auto weakThis = weak_from_this(); |
| 334 | requestManager->performRequest( |
| 335 | request, HTTPRequestManagerUtils::makeRequestCompletion([=](Result<snap::valdi_core::HTTPResponse> response) { |
| 336 | auto strongThis = weakThis.lock(); |
| 337 | if (strongThis == nullptr) { |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | strongThis->remoteResponseReceived(task, std::move(response)); |
| 342 | })); |
| 343 | } |
| 344 | |
| 345 | void RemoteDownloader::doLoad(const Shared<RemoteDownloaderTask>& task) { |
| 346 | if (task->getUrl().hasPrefix("file://")) { |
nothing calls this directly
no test coverage detected