Commits

Liam Staskawicz committed 9c54375

* slightly more complete

Comments (0)

Files changed (2)

fan/bson/BsonReader.fan

         if(len + 4 != totallen)
           throw MongoOpErr("BSON - bad data size got subtype 0x02 len: $len, totallen: $totallen")
         val = ins.readBufFully(null, len)
+      default:
+        val = ins.readBufFully(null, totallen)
     }
-    
     bson[name] = val
     return remaining - (name.size + totallen + 6)  // 6 == 1 null, 4 len, 1 type
   }

fan/bson/BsonWriter.fan

   {
     b.write(Bson.BINARY)
     writeCStr(b.out, key)
-    b.writeI4(bin.size + 4).write(bbt).writeI4(bin.size)
+    switch(bbt) {
+      case Bson.BIN_LENGTH:
+        b.writeI4(bin.size + 4).write(bbt).writeI4(bin.size)
+      default:
+        b.writeI4(bin.size).write(bbt)
+    }
     // don't disturb the pos
     p := bin.pos
     b.writeBuf(bin)