diff --git a/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs b/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs index 9d1096ef..ade84b67 100644 --- a/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs +++ b/OpenMetaverse.StructuredData/LLSD/BinaryLLSD.cs @@ -74,25 +74,46 @@ namespace OpenMetaverse.StructuredData private static readonly byte[] llsdBinaryHeadBytes = Encoding.ASCII.GetBytes(llsdBinaryHead); /// - /// + /// Deserializes binary LLSD /// - /// - /// + /// Serialized data + /// OSD containting deserialized data public static OSD DeserializeLLSDBinary(byte[] binaryData) + { + return DeserializeLLSDBinary(binaryData, false); + } + + /// + /// Deserializes binary LLSD + /// + /// Serialized data + /// OSD containting deserialized data + public static OSD DeserializeLLSDBinary(byte[] binaryData, bool headerOptional) { MemoryStream stream = new MemoryStream(binaryData); - OSD osd = DeserializeLLSDBinary(stream); + OSD osd = DeserializeLLSDBinary(stream, headerOptional); stream.Close(); return osd; } /// - /// + /// Deserializes binary LLSD /// - /// - /// + /// Stream to read the data from + /// OSD containting deserialized data public static OSD DeserializeLLSDBinary(Stream stream) + { + return DeserializeLLSDBinary(stream, false); + } + + /// + /// Deserializes binary LLSD + /// + /// Stream to read the data from + /// Treat LLSD binary header as optional + /// OSD containting deserialized data + public static OSD DeserializeLLSDBinary(Stream stream, bool headerOptional) { if (!stream.CanSeek) throw new OSDException("Cannot deserialize binary LLSD from unseekable streams"); @@ -100,7 +121,8 @@ namespace OpenMetaverse.StructuredData SkipWhiteSpace(stream); if (!FindString(stream, llsdBinaryHead) && !FindString(stream, llsdBinaryHead2)) - throw new OSDException("Failed to decode binary LLSD"); + if (!headerOptional) + throw new OSDException("Failed to decode binary LLSD"); SkipWhiteSpace(stream);