Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions native~/Shared/src/UnityAssetAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,30 @@
#include <DotNet/UnityEngine/Networking/UploadHandler.h>
#include <DotNet/UnityEngine/Networking/UploadHandlerRaw.h>

#include <sstream>

using namespace CesiumAsync;
using namespace CesiumUtility;
using namespace DotNet;

namespace {

std::string encodeUTF8toASCII(const std::string& input) {
std::ostringstream ss;
bool includePrefix = false;
for (const unsigned char c : input) {
if (c == 32) {
ss << "%20"; // replace spaces with %20
} else if (c < 128) {
ss << c;
} else {
includePrefix = true;
ss << "%" << std::hex << static_cast<int>(c);
}
}
return includePrefix ? "utf-8''" + ss.str() : ss.str();
}

class UnityAssetResponse : public IAssetResponse {
public:
UnityAssetResponse(
Expand Down Expand Up @@ -95,12 +113,12 @@ class UnityAssetRequest : public IAssetRequest {
namespace CesiumForUnityNative {

UnityAssetAccessor::UnityAssetAccessor()
: _cesiumPlatformHeader(
: _cesiumPlatformHeader(encodeUTF8toASCII(
CesiumForUnity::Helpers::ToString(
UnityEngine::Application::platform())
.ToStlString() +
" " + System::Environment::OSVersion().VersionString().ToStlString() +
" " + UnityEngine::Application::productName().ToStlString()),
" " + UnityEngine::Application::productName().ToStlString())),
_cesiumVersionHeader(
CesiumForUnityNative::Cesium::version + " " +
CesiumForUnityNative::Cesium::commit) {}
Expand Down