1

我正在模拟发送一个 JSON 请求 ~500kb。该测试不是测试请求中的内容,只是测试这种大小的 JSON 请求将放在服务器上的负载。

代码如下:

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)) 

发送请求后,我收到一条错误消息,指出 JSON 请求的格式不正确。这可能是 Base64 编码的问题(使用 sun.misc.BASE64Encoder())吗?

4

0 回答 0