diff options
| author | zousar <[email protected]> | 2025-03-21 22:53:59 -0600 |
|---|---|---|
| committer | zousar <[email protected]> | 2025-03-21 22:53:59 -0600 |
| commit | 8878156f30e375b93ebe99f02d94c581bcbbf43c (patch) | |
| tree | 5399a090e49d6398be34d7b292721d69ccac6c87 /src/zenserver/projectstore/projectstore.cpp | |
| parent | don't let auth env argument block other auth options (#316) (diff) | |
| download | zen-8878156f30e375b93ebe99f02d94c581bcbbf43c.tar.xz zen-8878156f30e375b93ebe99f02d94c581bcbbf43c.zip | |
Add CookPackageArtifacts attachment to web ui
Diffstat (limited to 'src/zenserver/projectstore/projectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index 86791e29a..1132e458e 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -4812,11 +4812,46 @@ ProjectStore::GetChunk(const std::string_view ProjectId, } } - if (AcceptType == ZenContentType::kUnknownContentType || AcceptType == ZenContentType::kBinary) + if (AcceptType == ZenContentType::kUnknownContentType || AcceptType == ZenContentType::kBinary || AcceptType == ZenContentType::kJSON || + AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject) { - CompressedBuffer Compressed = CompressedBuffer::FromCompressedNoValidate(std::move(OutChunk)); - OutChunk = Compressed.Decompress().AsIoBuffer(); - OutChunk.SetContentType(ZenContentType::kBinary); + CompressedBuffer Compressed = CompressedBuffer::FromCompressedNoValidate(std::move(OutChunk)); + IoBuffer DecompressedBuffer = Compressed.Decompress().AsIoBuffer(); + + if (AcceptType == ZenContentType::kJSON || AcceptType == ZenContentType::kYAML || AcceptType == ZenContentType::kCbObject) + { + CbValidateError CbErr = ValidateCompactBinary(DecompressedBuffer.GetView(), CbValidateMode::Default); + if (!!CbErr) + { + return {HttpResponseCode::NotAcceptable, fmt::format("chunk - '{}' WRONGTYPE", Cid)}; + } + + if (AcceptType == HttpContentType::kJSON || AcceptType == HttpContentType::kYAML) + { + CbObject ContainerObject = LoadCompactBinaryObject(DecompressedBuffer); + ExtendableStringBuilder<1024> Sb; + if (AcceptType == HttpContentType::kJSON) + { + ContainerObject.ToJson(Sb); + } + else if (AcceptType == HttpContentType::kYAML) + { + ContainerObject.ToYaml(Sb); + } + IoBuffer SerializedBuffer(IoBuffer::Clone, Sb.Data(), Sb.Size()); + OutChunk = SerializedBuffer; + } + else + { + OutChunk = DecompressedBuffer; + } + OutChunk.SetContentType(AcceptType); + } + else + { + OutChunk = DecompressedBuffer; + OutChunk.SetContentType(ZenContentType::kBinary); + } } else { |