1

I'm simulating sending a JSON request ~500kb. The test isn't testing what's in the request simply testing the load a JSON request of this size would place on server.

Code is as follows:

val values =
"""
  |"created" : "now",
  |"metaData" : "%s",
  |"_bufferMetaData" : "%s",
  |"_bufferEventHistory" : "%s",
  |"_bufferPositions" : "%s",
  |"_bufferStringTable" : "%s"
""".stripMargin

val created ="now".getBytes()
val metaData = Storage.base64.encode(Array.fill(intsPerArray) ( (nextInt(256) - 128).toByte ))
val bufferMetaData = Storage.base64.encode(Array.fill(intsPerArray) ( (nextInt(256) - 128).toByte ))
val bufferEventHistory = Storage.base64.encode(Array.fill(intsPerArray) ( (nextInt(256) - 128).toByte ))
val bufferPosition = Storage.base64.encode(Array.fill(intsPerArray) ( (nextInt(256) - 128).toByte ))
val bufferStringTable = Storage.base64.encode(Array.fill(intsPerArray) ( (nextInt(256) - 128).toByte ))

Storage.item.insert("replays", values.format(metaData, bufferMetaData, bufferEventHistory, bufferPosition, bufferStringTable)) 

Upon sending request, I am recieving an error stating that JSON request is not formatted correctly. Could this be an issue with the Base64 encoding(using sun.misc.BASE64Encoder())?

user2313658
  • 41
  • 1
  • 2
  • 7

0 Answers0