From 96672becc68dc2fac3db410017aff5d6aea68dad Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 15 Aug 2017 15:19:20 -0700 Subject: [PATCH] read redirected path info in MappingRequest --- assignment-client/src/assets/AssetServer.cpp | 2 +- libraries/networking/src/MappingRequest.cpp | 11 +++++++++++ libraries/networking/src/MappingRequest.h | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/assets/AssetServer.cpp b/assignment-client/src/assets/AssetServer.cpp index f82ef702f0..2082856f56 100644 --- a/assignment-client/src/assets/AssetServer.cpp +++ b/assignment-client/src/assets/AssetServer.cpp @@ -314,7 +314,7 @@ void AssetServer::handleGetMappingOperation(ReceivedMessage& message, SharedNode replyPacket.writePrimitive(wasRedirected); // include the re-directed path in case the caller needs to make relative path requests for the baked asset - replyPacket.write(bakedAssetPath.toUtf8()); + replyPacket.writeString(bakedAssetPath); } else { replyPacket.write(QByteArray::fromHex(originalAssetHash.toUtf8())); diff --git a/libraries/networking/src/MappingRequest.cpp b/libraries/networking/src/MappingRequest.cpp index 810b5b376d..bd7c05bdf7 100644 --- a/libraries/networking/src/MappingRequest.cpp +++ b/libraries/networking/src/MappingRequest.cpp @@ -87,6 +87,17 @@ void GetMappingRequest::doStart() { if (!_error) { _hash = message->read(SHA256_HASH_LENGTH).toHex(); + + // check the boolean to see if this request got re-directed + quint8 wasRedirected; + message->readPrimitive(&wasRedirected); + _wasRedirected = wasRedirected; + + // if it did grab that re-directed path + if (_wasRedirected) { + _redirectedPath = message->readString(); + } + } emit finished(this); }); diff --git a/libraries/networking/src/MappingRequest.h b/libraries/networking/src/MappingRequest.h index 85b68e2427..e1cd8a39e8 100644 --- a/libraries/networking/src/MappingRequest.h +++ b/libraries/networking/src/MappingRequest.h @@ -53,6 +53,8 @@ public: GetMappingRequest(const AssetPath& path); AssetHash getHash() const { return _hash; } + AssetPath getRedirectedPath() const { return _redirectedPath; } + bool wasRedirected() const { return _wasRedirected; } signals: void finished(GetMappingRequest* thisRequest); @@ -62,6 +64,10 @@ private: AssetPath _path; AssetHash _hash; + + + AssetPath _redirectedPath; + bool _wasRedirected { false }; }; class SetMappingRequest : public MappingRequest {