Commit c27cd8b4 authored by Paweł Wegner's avatar Paweł Wegner
Browse files

MegaNz: start streaming after checking headers.

parent e10b5488
...@@ -310,12 +310,6 @@ IHttpServer::IResponse::Pointer MegaNz::HttpServerCallback::receivedConnection( ...@@ -310,12 +310,6 @@ IHttpServer::IResponse::Pointer MegaNz::HttpServerCallback::receivedConnection(
std::unique_ptr<mega::MegaNode> node(provider_->mega()->getNodeByPath(file)); std::unique_ptr<mega::MegaNode> node(provider_->mega()->getNodeByPath(file));
if (!node) if (!node)
return server.createResponse(IHttpRequest::NotFound, {}, "file not found"); return server.createResponse(IHttpRequest::NotFound, {}, "file not found");
auto buffer = std::make_shared<Buffer>(connection);
auto data = util::make_unique<HttpData>(buffer);
auto request = std::make_shared<Request<EitherError<void>>>(
std::weak_ptr<CloudProvider>(provider_->shared_from_this()));
data->request_ = request;
provider_->addStreamRequest(request);
int code = IHttpRequest::Ok; int code = IHttpRequest::Ok;
auto extension = auto extension =
static_cast<Item*>(provider_->toItem(node.get()).get())->extension(); static_cast<Item*>(provider_->toItem(node.get()).get())->extension();
...@@ -337,6 +331,12 @@ IHttpServer::IResponse::Pointer MegaNz::HttpServerCallback::receivedConnection( ...@@ -337,6 +331,12 @@ IHttpServer::IResponse::Pointer MegaNz::HttpServerCallback::receivedConnection(
headers["Content-Range"] = stream.str(); headers["Content-Range"] = stream.str();
code = IHttpRequest::Partial; code = IHttpRequest::Partial;
} }
auto buffer = std::make_shared<Buffer>(connection);
auto data = util::make_unique<HttpData>(buffer);
auto request = std::make_shared<Request<EitherError<void>>>(
std::weak_ptr<CloudProvider>(provider_->shared_from_this()));
data->request_ = request;
provider_->addStreamRequest(request);
request->set(provider_->downloadResolver( request->set(provider_->downloadResolver(
provider_->toItem(node.get()), provider_->toItem(node.get()),
util::make_unique<HttpDataCallback>(buffer), range.start, range.size)); util::make_unique<HttpDataCallback>(buffer), range.start, range.size));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment